<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Google App Engine + JAVA + JDO + Inheritance + One-To-Many Relationships</title>
	<atom:link href="http://www.wetfeetblog.com/google-app-engine-java-jdo-inheritance-one-to-many-relationships/242/feed" rel="self" type="application/rss+xml" />
	<link>http://www.wetfeetblog.com/google-app-engine-java-jdo-inheritance-one-to-many-relationships/242</link>
	<description></description>
	<lastBuildDate>Sun, 22 Jan 2012 04:28:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Song Jing, Lim</title>
		<link>http://www.wetfeetblog.com/google-app-engine-java-jdo-inheritance-one-to-many-relationships/242/comment-page-1#comment-1122</link>
		<dc:creator>Song Jing, Lim</dc:creator>
		<pubDate>Sun, 22 Jan 2012 04:28:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.wetfeetblog.com/?p=242#comment-1122</guid>
		<description>Hi

Based on GAE JDO page (http://code.google.com/appengine/docs/java/datastore/jdo/relationships.html), I create Employee and ContactInfo objects with relation one to many.

    public class Employee implements Serializable{
        @Persistent(mappedBy = &quot;employee&quot;, defaultFetchGroup = &quot;true&quot;)
        @Element(dependent = &quot;true&quot;)
        private List contactInfoSets;
    ...

    public class ContactInfo implements Serializable{
        @Persistent
        private String streetAddress;
    ...

I try to exec below code always give me error (java.lang.AssertionError: expected: but was:) because but the return value is 0.

    String statement = &quot;SELECT FROM &quot; + Employee.class.getName() 
        + &quot; WHERE contactInfoSets.contains(i) &amp;&amp; i.streetAddress==&#039;myaddress&#039;&quot;
        + &quot; VARIABLES &quot; + ContactInfo.class.getName() + &quot; i &quot;;
    javax.jdo.Query query = pm.newQuery(statement);
    List companyProfiles = (List) query.execute();

Thanks...  
		

Here the code

**[Employee.java]**

    import java.io.Serializable;
    import java.util.List;
    
    import javax.jdo.annotations.IdGeneratorStrategy;
    import javax.jdo.annotations.IdentityType;
    import javax.jdo.annotations.PersistenceCapable;
    import javax.jdo.annotations.Persistent;
    import javax.jdo.annotations.PrimaryKey;
    import javax.jdo.annotations.Element;
    
    import com.google.appengine.api.datastore.Key;
    
    @SuppressWarnings(&quot;serial&quot;)
    @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = &quot;true&quot;)
    public class Employee implements Serializable{
    
        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;
    
        @Persistent(mappedBy = &quot;employee&quot;, defaultFetchGroup = &quot;true&quot;)
        @Element(dependent = &quot;true&quot;)
        private List contactInfoSets;
    
    	public List getContactInfoSets() {
    		return contactInfoSets;
    	}
    	public void setContactInfoSets(List contactInfoSets) {
    		this.contactInfoSets = contactInfoSets;
    	}
    	public Key getKey() {
    		return key;
    	}
    	public void setKey(Key key) {
    		this.key = key;
    	}
    }


**[ContactInfo.java]**

    import java.io.Serializable;
    
    import javax.jdo.annotations.IdGeneratorStrategy;
    import javax.jdo.annotations.IdentityType;
    import javax.jdo.annotations.PersistenceCapable;
    import javax.jdo.annotations.Persistent;
    import javax.jdo.annotations.PrimaryKey;
    
    import com.google.appengine.api.datastore.Key;
    
    @SuppressWarnings(&quot;serial&quot;)
    @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = &quot;true&quot;)
    public class ContactInfo implements Serializable{
    
        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;
    
    	
    	@Persistent
    	private String streetAddress;
    	
    	@Persistent
        private Employee employee;		
    
    	public Key getKey() {
    		return key;
    	}
    
    	public void setKey(Key key) {
    		this.key = key;
    	}	
    	
    	public String getStreetAddress() {
    		return streetAddress;
    	}
    
    	public void setStreetAddress(String streetAddress) {
    		this.streetAddress = streetAddress;
    	}
    
    	public Employee getEmployee() {
    		return employee;
    	}
    
    	public void setEmployee(Employee employee) {
    		this.employee = employee;
    	}	
    }

**[TestJdoCollection.java]**

    import static com.google.appengine.api.datastore.FetchOptions.Builder.withLimit;
    import static org.junit.Assert.assertEquals;
    
    import java.util.ArrayList;
    import java.util.List;
    
    import javax.jdo.PersistenceManager;
    import javax.jdo.PersistenceManagerFactory;
    
    import org.junit.After;
    import org.junit.Before;
    import org.junit.Test;
    
    import com.cea.common.service.CeaServiceFactory;
    import com.cea.common.service.PersistenceService;
    import com.google.appengine.api.datastore.DatastoreService;
    import com.google.appengine.api.datastore.DatastoreServiceFactory;
    import com.google.appengine.api.datastore.Query;
    import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
    import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
    
    public class TestJdoCollection {
    private final LocalServiceTestHelper helper = new LocalServiceTestHelper(
			new LocalDatastoreServiceTestConfig());   
                    
    	private DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
    	
    	@Before
    	public void setUp() {
    		helper.setUp();
    	}
    
    	@After
    	public void tearDown() {
    		helper.tearDown();
    	}
    
        @Test	
    	public void test(){
        	CeaServiceFactory ceaServiceFactory = CeaServiceFactory.getInstance();
    		PersistenceService servicePersistance = (PersistenceService) ceaServiceFactory.getCeaService(CeaServiceFactory.SERVICE_PERSISTANCE);		
    		PersistenceManagerFactory pmf = servicePersistance.getPersistenceManagerFactory();
    		PersistenceManager pm = pmf.getPersistenceManager();
    		
        	ContactInfo contactInfo = new ContactInfo();
        	contactInfo.setStreetAddress(&quot;myaddress&quot;);
        	
        	Employee employee  = new Employee();
        	List contactInfoSets = new ArrayList();
        	contactInfoSets.add(contactInfo);
        	employee.setContactInfoSets(contactInfoSets);		
    
    		pm.makePersistent(employee);
    		
    		assertEquals(1, ds.prepare(new Query(&quot;Employee&quot;)).countEntities(withLimit(10)));
    		assertEquals(1, ds.prepare(new Query(&quot;ContactInfo&quot;)).countEntities(withLimit(10)));
    		
    		String statement = &quot;SELECT FROM &quot; + Employee.class.getName() + &quot; WHERE contactInfoSets.contains(i) &amp;&amp; i.streetAddress==&#039;myaddress&#039;&quot;
    				+ &quot; VARIABLES &quot; + ContactInfo.class.getName() + &quot; i &quot;;
    		javax.jdo.Query query = pm.newQuery(statement);
    	    List companyProfiles = (List) query.execute();		
    	    assertEquals(1, companyProfiles.size());
        	
    	}
    }</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>Based on GAE JDO page (<a href="http://code.google.com/appengine/docs/java/datastore/jdo/relationships.html" rel="nofollow">http://code.google.com/appengine/docs/java/datastore/jdo/relationships.html</a>), I create Employee and ContactInfo objects with relation one to many.</p>
<p>    public class Employee implements Serializable{<br />
        @Persistent(mappedBy = &#8220;employee&#8221;, defaultFetchGroup = &#8220;true&#8221;)<br />
        @Element(dependent = &#8220;true&#8221;)<br />
        private List contactInfoSets;<br />
    &#8230;</p>
<p>    public class ContactInfo implements Serializable{<br />
        @Persistent<br />
        private String streetAddress;<br />
    &#8230;</p>
<p>I try to exec below code always give me error (java.lang.AssertionError: expected: but was:) because but the return value is 0.</p>
<p>    String statement = &#8220;SELECT FROM &#8221; + Employee.class.getName()<br />
        + &#8221; WHERE contactInfoSets.contains(i) &amp;&amp; i.streetAddress==&#8217;myaddress&#8217;&#8221;<br />
        + &#8221; VARIABLES &#8221; + ContactInfo.class.getName() + &#8221; i &#8220;;<br />
    javax.jdo.Query query = pm.newQuery(statement);<br />
    List companyProfiles = (List) query.execute();</p>
<p>Thanks&#8230;  </p>
<p>Here the code</p>
<p>**[Employee.java]**</p>
<p>    import java.io.Serializable;<br />
    import java.util.List;</p>
<p>    import javax.jdo.annotations.IdGeneratorStrategy;<br />
    import javax.jdo.annotations.IdentityType;<br />
    import javax.jdo.annotations.PersistenceCapable;<br />
    import javax.jdo.annotations.Persistent;<br />
    import javax.jdo.annotations.PrimaryKey;<br />
    import javax.jdo.annotations.Element;</p>
<p>    import com.google.appengine.api.datastore.Key;</p>
<p>    @SuppressWarnings(&#8220;serial&#8221;)<br />
    @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = &#8220;true&#8221;)<br />
    public class Employee implements Serializable{</p>
<p>        @PrimaryKey<br />
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)<br />
        private Key key;</p>
<p>        @Persistent(mappedBy = &#8220;employee&#8221;, defaultFetchGroup = &#8220;true&#8221;)<br />
        @Element(dependent = &#8220;true&#8221;)<br />
        private List contactInfoSets;</p>
<p>    	public List getContactInfoSets() {<br />
    		return contactInfoSets;<br />
    	}<br />
    	public void setContactInfoSets(List contactInfoSets) {<br />
    		this.contactInfoSets = contactInfoSets;<br />
    	}<br />
    	public Key getKey() {<br />
    		return key;<br />
    	}<br />
    	public void setKey(Key key) {<br />
    		this.key = key;<br />
    	}<br />
    }</p>
<p>**[ContactInfo.java]**</p>
<p>    import java.io.Serializable;</p>
<p>    import javax.jdo.annotations.IdGeneratorStrategy;<br />
    import javax.jdo.annotations.IdentityType;<br />
    import javax.jdo.annotations.PersistenceCapable;<br />
    import javax.jdo.annotations.Persistent;<br />
    import javax.jdo.annotations.PrimaryKey;</p>
<p>    import com.google.appengine.api.datastore.Key;</p>
<p>    @SuppressWarnings(&#8220;serial&#8221;)<br />
    @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = &#8220;true&#8221;)<br />
    public class ContactInfo implements Serializable{</p>
<p>        @PrimaryKey<br />
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)<br />
        private Key key;</p>
<p>    	@Persistent<br />
    	private String streetAddress;</p>
<p>    	@Persistent<br />
        private Employee employee;		</p>
<p>    	public Key getKey() {<br />
    		return key;<br />
    	}</p>
<p>    	public void setKey(Key key) {<br />
    		this.key = key;<br />
    	}	</p>
<p>    	public String getStreetAddress() {<br />
    		return streetAddress;<br />
    	}</p>
<p>    	public void setStreetAddress(String streetAddress) {<br />
    		this.streetAddress = streetAddress;<br />
    	}</p>
<p>    	public Employee getEmployee() {<br />
    		return employee;<br />
    	}</p>
<p>    	public void setEmployee(Employee employee) {<br />
    		this.employee = employee;<br />
    	}<br />
    }</p>
<p>**[TestJdoCollection.java]**</p>
<p>    import static com.google.appengine.api.datastore.FetchOptions.Builder.withLimit;<br />
    import static org.junit.Assert.assertEquals;</p>
<p>    import java.util.ArrayList;<br />
    import java.util.List;</p>
<p>    import javax.jdo.PersistenceManager;<br />
    import javax.jdo.PersistenceManagerFactory;</p>
<p>    import org.junit.After;<br />
    import org.junit.Before;<br />
    import org.junit.Test;</p>
<p>    import com.cea.common.service.CeaServiceFactory;<br />
    import com.cea.common.service.PersistenceService;<br />
    import com.google.appengine.api.datastore.DatastoreService;<br />
    import com.google.appengine.api.datastore.DatastoreServiceFactory;<br />
    import com.google.appengine.api.datastore.Query;<br />
    import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;<br />
    import com.google.appengine.tools.development.testing.LocalServiceTestHelper;</p>
<p>    public class TestJdoCollection {<br />
    private final LocalServiceTestHelper helper = new LocalServiceTestHelper(<br />
			new LocalDatastoreServiceTestConfig());   </p>
<p>    	private DatastoreService ds = DatastoreServiceFactory.getDatastoreService();</p>
<p>    	@Before<br />
    	public void setUp() {<br />
    		helper.setUp();<br />
    	}</p>
<p>    	@After<br />
    	public void tearDown() {<br />
    		helper.tearDown();<br />
    	}</p>
<p>        @Test<br />
    	public void test(){<br />
        	CeaServiceFactory ceaServiceFactory = CeaServiceFactory.getInstance();<br />
    		PersistenceService servicePersistance = (PersistenceService) ceaServiceFactory.getCeaService(CeaServiceFactory.SERVICE_PERSISTANCE);<br />
    		PersistenceManagerFactory pmf = servicePersistance.getPersistenceManagerFactory();<br />
    		PersistenceManager pm = pmf.getPersistenceManager();</p>
<p>        	ContactInfo contactInfo = new ContactInfo();<br />
        	contactInfo.setStreetAddress(&#8220;myaddress&#8221;);</p>
<p>        	Employee employee  = new Employee();<br />
        	List contactInfoSets = new ArrayList();<br />
        	contactInfoSets.add(contactInfo);<br />
        	employee.setContactInfoSets(contactInfoSets);		</p>
<p>    		pm.makePersistent(employee);</p>
<p>    		assertEquals(1, ds.prepare(new Query(&#8220;Employee&#8221;)).countEntities(withLimit(10)));<br />
    		assertEquals(1, ds.prepare(new Query(&#8220;ContactInfo&#8221;)).countEntities(withLimit(10)));</p>
<p>    		String statement = &#8220;SELECT FROM &#8221; + Employee.class.getName() + &#8221; WHERE contactInfoSets.contains(i) &amp;&amp; i.streetAddress==&#8217;myaddress&#8217;&#8221;<br />
    				+ &#8221; VARIABLES &#8221; + ContactInfo.class.getName() + &#8221; i &#8220;;<br />
    		javax.jdo.Query query = pm.newQuery(statement);<br />
    	    List companyProfiles = (List) query.execute();<br />
    	    assertEquals(1, companyProfiles.size());</p>
<p>    	}<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blake Wichmann</title>
		<link>http://www.wetfeetblog.com/google-app-engine-java-jdo-inheritance-one-to-many-relationships/242/comment-page-1#comment-1089</link>
		<dc:creator>Blake Wichmann</dc:creator>
		<pubDate>Wed, 13 Jul 2011 14:46:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.wetfeetblog.com/?p=242#comment-1089</guid>
		<description>My brother informed me with regards to your site. They were right, I&#039;m really astounded with all the publishing and slick layout. It appears in my experience you’re basically scratching the surface on the subject of whatever you might carry out, yet you’re off towards a excellent start! I decided to include this site to my personal bookmark webpage along with I recently joined your rss.</description>
		<content:encoded><![CDATA[<p>My brother informed me with regards to your site. They were right, I&#8217;m really astounded with all the publishing and slick layout. It appears in my experience you’re basically scratching the surface on the subject of whatever you might carry out, yet you’re off towards a excellent start! I decided to include this site to my personal bookmark webpage along with I recently joined your rss.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete</title>
		<link>http://www.wetfeetblog.com/google-app-engine-java-jdo-inheritance-one-to-many-relationships/242/comment-page-1#comment-1088</link>
		<dc:creator>Pete</dc:creator>
		<pubDate>Mon, 18 Apr 2011 15:43:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.wetfeetblog.com/?p=242#comment-1088</guid>
		<description>That&#039;s an excellent post, thank you. One thing I am still struggling to get my head around is how to run a query that will return parent objects filtered by some property of the child object. 
Can you give an example of how you would get a list of all customers with and address where city =  &quot;New York&quot;?</description>
		<content:encoded><![CDATA[<p>That&#8217;s an excellent post, thank you. One thing I am still struggling to get my head around is how to run a query that will return parent objects filtered by some property of the child object.<br />
Can you give an example of how you would get a list of all customers with and address where city =  &#8220;New York&#8221;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tomas Mazukna</title>
		<link>http://www.wetfeetblog.com/google-app-engine-java-jdo-inheritance-one-to-many-relationships/242/comment-page-1#comment-1076</link>
		<dc:creator>Tomas Mazukna</dc:creator>
		<pubDate>Wed, 16 Mar 2011 16:36:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.wetfeetblog.com/?p=242#comment-1076</guid>
		<description>Kostai,
You do not have to write query. Get your parent by ID and then access the collection of children in the parent and you have them.
Tomas</description>
		<content:encoded><![CDATA[<p>Kostai,<br />
You do not have to write query. Get your parent by ID and then access the collection of children in the parent and you have them.<br />
Tomas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kostas Trichas</title>
		<link>http://www.wetfeetblog.com/google-app-engine-java-jdo-inheritance-one-to-many-relationships/242/comment-page-1#comment-1075</link>
		<dc:creator>Kostas Trichas</dc:creator>
		<pubDate>Wed, 16 Mar 2011 11:28:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.wetfeetblog.com/?p=242#comment-1075</guid>
		<description>Hi Thomas, very good example :)
Can i ask you a simple questiion please?
How can i write a query that returns all the children objects of the parent?
In this example let&#039;s say all addresses of the customer.</description>
		<content:encoded><![CDATA[<p>Hi Thomas, very good example <img src='http://www.wetfeetblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Can i ask you a simple questiion please?<br />
How can i write a query that returns all the children objects of the parent?<br />
In this example let&#8217;s say all addresses of the customer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bev Deloye</title>
		<link>http://www.wetfeetblog.com/google-app-engine-java-jdo-inheritance-one-to-many-relationships/242/comment-page-1#comment-520</link>
		<dc:creator>Bev Deloye</dc:creator>
		<pubDate>Sun, 21 Nov 2010 02:38:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.wetfeetblog.com/?p=242#comment-520</guid>
		<description>I recently stumbled on your blog and happen to be reading along. I imagined I would go away my 1st remark. I don’t know what to say except that I&#039;ve enjoyed reading.Great web site,I&#039;ll retain visiting this blog site quite frequently.</description>
		<content:encoded><![CDATA[<p>I recently stumbled on your blog and happen to be reading along. I imagined I would go away my 1st remark. I don’t know what to say except that I&#8217;ve enjoyed reading.Great web site,I&#8217;ll retain visiting this blog site quite frequently.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: duke</title>
		<link>http://www.wetfeetblog.com/google-app-engine-java-jdo-inheritance-one-to-many-relationships/242/comment-page-1#comment-507</link>
		<dc:creator>duke</dc:creator>
		<pubDate>Fri, 27 Aug 2010 14:45:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.wetfeetblog.com/?p=242#comment-507</guid>
		<description>Hello,
i am wandering something in a relationship 1/N normally you could do like cghersi&#039;s example. But GWT&#039;s client part needs source code of the classes it uses, so Key source code is needed. At execution time GWT will complains. How would you create a 1/N relationship without a Key class ?
(i saw a workaround creating a source code of the Key.java but it&#039;s just a hack)
Thanks</description>
		<content:encoded><![CDATA[<p>Hello,<br />
i am wandering something in a relationship 1/N normally you could do like cghersi&#8217;s example. But GWT&#8217;s client part needs source code of the classes it uses, so Key source code is needed. At execution time GWT will complains. How would you create a 1/N relationship without a Key class ?<br />
(i saw a workaround creating a source code of the Key.java but it&#8217;s just a hack)<br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cghersi</title>
		<link>http://www.wetfeetblog.com/google-app-engine-java-jdo-inheritance-one-to-many-relationships/242/comment-page-1#comment-506</link>
		<dc:creator>cghersi</dc:creator>
		<pubDate>Thu, 26 Aug 2010 08:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.wetfeetblog.com/?p=242#comment-506</guid>
		<description>Hi Tomas, thank you for the excellent example!!

I&#039;m struggling with a strange problem with JDO.
I&#039;ve got two PersistenCapable classes, one having a Collection of
objects of the second, something like this:

class First {
 @Persistent
 @PrimaryKey
 Long id;

 @Persistent(mappedby=&quot;owner&quot;)
 ArrayList list = new ArrayList();

 ArrayList getList() {
 if (list == null)
  list=new ArrayList();
 return list;
 }

...
}

class Second {
 @Persistent
 @PrimaryKey
 Key id;

 @Persistent
 First owner;

 First getOwner() {
 if (owner==null)
  owner = new First();
 return owner;

 ...
}

Seems to be quite the same as you example, right?

In another class I need to print the owner of all my First objects, so
I do:
First obj = ...;
ArrayList list = obj.getList();
for (Second s : list) {
 System.out.println(s.getOwner());
}

In this loop, I find some Second object having null owner, and I
cannot understand why.
Now I have several questions about my data modelling:
1) Do I need to mark any field with (defaultFetchGroup = &quot;true&quot;)
annotation?
2) Does the check on null object (e.g. if (owner==null) owner = new
First();) in the getter methods results in any strange behavior?
3) Does the assignment on definition of objects (e.g.
ArrayList list = new ArrayList();) results in any
strange behavior?
4) Do I need to add any other annotation to owner field of Second
class?

Thank you very much for your help!!
Best regards
cghersi</description>
		<content:encoded><![CDATA[<p>Hi Tomas, thank you for the excellent example!!</p>
<p>I&#8217;m struggling with a strange problem with JDO.<br />
I&#8217;ve got two PersistenCapable classes, one having a Collection of<br />
objects of the second, something like this:</p>
<p>class First {<br />
 @Persistent<br />
 @PrimaryKey<br />
 Long id;</p>
<p> @Persistent(mappedby=&#8221;owner&#8221;)<br />
 ArrayList list = new ArrayList();</p>
<p> ArrayList getList() {<br />
 if (list == null)<br />
  list=new ArrayList();<br />
 return list;<br />
 }</p>
<p>&#8230;<br />
}</p>
<p>class Second {<br />
 @Persistent<br />
 @PrimaryKey<br />
 Key id;</p>
<p> @Persistent<br />
 First owner;</p>
<p> First getOwner() {<br />
 if (owner==null)<br />
  owner = new First();<br />
 return owner;</p>
<p> &#8230;<br />
}</p>
<p>Seems to be quite the same as you example, right?</p>
<p>In another class I need to print the owner of all my First objects, so<br />
I do:<br />
First obj = &#8230;;<br />
ArrayList list = obj.getList();<br />
for (Second s : list) {<br />
 System.out.println(s.getOwner());<br />
}</p>
<p>In this loop, I find some Second object having null owner, and I<br />
cannot understand why.<br />
Now I have several questions about my data modelling:<br />
1) Do I need to mark any field with (defaultFetchGroup = &#8220;true&#8221;)<br />
annotation?<br />
2) Does the check on null object (e.g. if (owner==null) owner = new<br />
First();) in the getter methods results in any strange behavior?<br />
3) Does the assignment on definition of objects (e.g.<br />
ArrayList list = new ArrayList();) results in any<br />
strange behavior?<br />
4) Do I need to add any other annotation to owner field of Second<br />
class?</p>
<p>Thank you very much for your help!!<br />
Best regards<br />
cghersi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tomas Mazukna</title>
		<link>http://www.wetfeetblog.com/google-app-engine-java-jdo-inheritance-one-to-many-relationships/242/comment-page-1#comment-502</link>
		<dc:creator>Tomas Mazukna</dc:creator>
		<pubDate>Tue, 06 Jul 2010 12:35:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.wetfeetblog.com/?p=242#comment-502</guid>
		<description>Its the same as ModelBase, I just copy-pasted from different Project where it is called EntityBase.</description>
		<content:encoded><![CDATA[<p>Its the same as ModelBase, I just copy-pasted from different Project where it is called EntityBase.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prabuddha</title>
		<link>http://www.wetfeetblog.com/google-app-engine-java-jdo-inheritance-one-to-many-relationships/242/comment-page-1#comment-501</link>
		<dc:creator>Prabuddha</dc:creator>
		<pubDate>Tue, 06 Jul 2010 11:02:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.wetfeetblog.com/?p=242#comment-501</guid>
		<description>Can you post the EntityBase class. Is it any different from the ModelBase class</description>
		<content:encoded><![CDATA[<p>Can you post the EntityBase class. Is it any different from the ModelBase class</p>
]]></content:encoded>
	</item>
</channel>
</rss>

