IF there won't be anyone answering such a simple question, I take it is not 
that simple. Or not working, so please take it out of the documentation 
(googlers). Thanks.
I haven't fixed it yet.

Still, I produced a stripped-down version that replicates the issue. And I 
also checked bugs lists, for both appengine and datanucleus-appengine ... 
no luck

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine-java/-/dM77KKc4RnAJ.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.annotations.Embedded;
import javax.jdo.annotations.EmbeddedOnly;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;



public class EmbeddedTest {
	// Nothing special here besides 
	// 'datanucleus.appengine.allowMultipleRelationsOfSameType' = true 
	private static final PersistenceManagerFactory pmfInstance =
		JDOHelper.getPersistenceManagerFactory("transactions-optional");	
	
	// Stripped down version, only having an id and embedded object
	@PersistenceCapable
	public static class User {
		@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
		@PrimaryKey
		Key id;
		
		@Persistent
		@Embedded
		UserDetails details;
		
		public User (String name) {
			this.details = new UserDetails(name);
		}
	}
	
	// The embedded object
	@PersistenceCapable
	@EmbeddedOnly
	public static class UserDetails {
		@Persistent
		String name;

		public UserDetails(String name) {
			this.name = name;
		}
	}
	
	LocalServiceTestHelper helper = new LocalServiceTestHelper(
			new LocalDatastoreServiceTestConfig());

	@Before
	public void setUp () {
		helper.setUp();
	}
	
	@After
	public void tearDown () {
		helper.tearDown();
	}
	
	@Test
	public void shouldHaveEmbeddedInfo () {
		final String name = "nameForTest"; 
		final User u = new User (name);
		
		PersistenceManager pm = pmfInstance.getPersistenceManager();
		final User uPersisted = pm.makePersistent(u);
		pm.close();
		
		Assert.assertNotNull(uPersisted);
		Assert.assertNotNull(uPersisted.details);
		// Make sure id is not null, we will fetch an User entity using it.
		Assert.assertNotNull(uPersisted.id);
		
		pm = pmfInstance.getPersistenceManager();
		final User uFetched = pm.getObjectById(User.class, uPersisted.id);
		
		Assert.assertNotNull(uFetched);
		Assert.assertNotNull(uFetched.id);
		Assert.assertNotNull(uFetched.details);
	}
}

Reply via email to