|
Another, I think important, information about the same problem, the children fields doesn't show up even in the admin console. I'm posting here my code so that everyone could check it out. ---------- Parent Class ----------- @PersistenceCapable(identityType = IdentityType.APPLICATION) public class User implements IsSerializable { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true") private String encodedKey; @Persistent private String userId; @Persistent(embedded="true", defaultFetchGroup="true") private Stat stat; public User() {} public String getEncodedKey() { return this.encodedKey; } public void setEncodedKey(String encodedKey) { this.encodedKey = encodedKey; } public void setUserId(String userId) { this.userId = userId; } public String getUserId() { return userId; } public Stat getStat() { return stat; } public void setStat(Stat stat) { this.stat = stat; } } -------- Child Class -------- @PersistenceCapable(identityType = IdentityType.APPLICATION) public class Stat implements GeneralStat { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true") private String encodedKey; @Persistent(mappedBy = "stat") private User user; @Persistent private String userId; public Stat() {} public String getEncodedKey() { return encodedKey; } public void setEncodedKey(String encodedKey) { this.encodedKey = encodedKey; } public String getUserId() { return userId; } public void setUserId(String userId) { this.userId = userId; } public User getUser() { return user; } public void setUser(User user) { this.user = user; } } --------- Code Snippet not working ---------- PersistenceManager pm = PMF.get().getPersistenceManager(); String userId = "test"; Key userKey = KeyFactory.createKey(User.class.getSimpleName(), userId); String userEncodedKey = KeyFactory.keyToString(userKey); User user = new User(); user.setUserId(userId); user.setEncodedKey(userEncodedKey); String statEncodedKey = KeyFactory.keyToString(userKey.getChild(Stat.class.getSimpleName(), userId)); Stat stat = new Stat(); stat.setUserId(userId); stat.setEncodedKey(statEncodedKey); user.setStat(stat); pm.makePersistent(stat); pm.makePersistent(user); pm.close(); pm = PMF.get().getPersistenceManager(); user = pm.getObjectById(User.class, userEncodedKey); Stat stat = user.getStat(); ------------------------------------- I think I'm doing a very basic thing: persist a one-to-one bidirectional relationship. Am I doing something wrong?? I can't really get it work... Please help..!! Thanks patrizio.munzi wrote: Hi, I'm having the same problem...When I try to fetch an object all its children fields are null. I tried to set defaultFetchGroup = "true" but nothing changed... Is there any work around for this??? I wouldn't want to pass to an unowned relationship... Thanks On Sep 16, 11:35 pm, "Jason (Google)" <[email protected]> wrote:Hi bysse. You only need to create custom indexes for composite queries, i.e. queries with two or more sort orders or queries with an equality filter on one property and an inequality filter on another. All single-property indexes are created by App Engine automatically, aside from Text and Blob fields and fields you explicitly mark as unindexed. I started seeing the same warning myself, although the end result was exactly what I wanted. This seems to only affect owned relationships -- if you're storing a Blob field or any other binary data, you should be able to continue using the defaultFetchGroup parameter; I'll have to follow up to see if there are any consequences to using this for owned relationships given that the datastore is returning the correct result. You can also nix the parameter and call something like getItemValues() before you close the PersistenceManager, which will also give the intended result without the warning. - Jason On Mon, Sep 14, 2009 at 12:01 PM, bysse <[email protected]> wrote: --
Patrizio Munzi --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en -~----------~----~----~----~------~----~------~--~--- |
- [appengine-java] Seeing different (incorrect?) JDO behavior... David
- [appengine-java] Re: Seeing different (incorrect?) JDO... Max Ross
- [appengine-java] Re: Seeing different (incorrect?) JDO... Jason (Google)
- [appengine-java] Re: Seeing different (incorrect?)... bysse
- [appengine-java] Re: Seeing different (incorre... Jason (Google)
- [appengine-java] Re: Seeing different (inc... patrizio.munzi
- [appengine-java] Re: Seeing different... Patrizio Munzi
- [appengine-java] Re: Seeing diffe... Ian Marshall
- [appengine-java] Re: Seeing d... Patrizio Munzi
- [appengine-java] Re: Seeing d... Ian Marshall
- [appengine-java] Re: Seeing d... Patrizio Munzi
- [appengine-java] Re: Seeing diffe... Marton Papp
