Hi Patrizio, I removed the _embedded="true"_ attribute from the mapping of the "stat" field and now it seems to be better. At least I can retrieve the object with the correct values. I have not checked the code in detail, but I guess if you are embedding Stat then you do not need a primary key for it anyway.
Marton On Sep 23, 2:39 pm, Patrizio Munzi <[email protected]> wrote: > 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:I'm having the same problem. If i > understand this correctly i must create an index for all fields in an entity. > Otherwise it will be null when i fetch the entity?If i set defaultFetchGroup > = "true" i get this message which doesn't look promising:8:55:05,144 WARN > [DataNucleus.MetaData] - Meta-data warning for Item.values: The datastore > does not support joins and therefore cannot honor requests to place child > objects in the default fetch group. The field will be fetched lazily on > first access. You can modify this warning by setting the > datanucleus.appengine.ignorableMetaDataBehavior property in your config. A > value of NONE will silence the warning. A value of ERROR will turn the > warning into an exception.Should i just set this property and ignore the > warning?/ErikOn Sep 8, 8:56 pm, "Jason (Google)"<[email protected]>wrote:Hi > David. I believe this is expected behavior -- unindexed properties, including > Text, Blob, and reference properties as well as descendants (PrivilegedUser > in this case) are not retrieved by default. There is an easier way to add a > field to the default fetch group:@Persistent(defaultFetchGroup = "true") > private PrivilegedUser privilegedUser;Can you let me know if this works for > you? If not, can you share your PrivilegedUser class definition?- JasonOn > Fri, Sep 4, 2009 at 9:56 PM, David<[email protected]>wrote:I’ve been > working with a fairly simple data model that has an Organization object which > contains some String members as well as a member variable of type > PrivilegedUser. And PrivilegedUser extends a User, and contains only a Key > and some String membe...@persistencecapable(identityType = > IdentityType.APPLICATION, detachable="true") public class Organization > implements Serializable { �...@primarykey > �...@persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private > Long id; �...@persistent private String organizationId;... > > read more » > > logo.gif > 1KViewDownload --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
