It looks like a 1 to 1 relationship so why not denormalize the name class to include the fields of your address class?
Jeff On Thu, Dec 2, 2010 at 7:19 PM, fb <[email protected]> wrote: > Hi, > > I have a question regarding querying when using unowned relationships. > I'm having real problems working this out due to no real JOIN syntax. > > Anyway, my problem is simple to explain. I have a Name class whose > objects I am persisting: > > @PersistenceCapable(identityType = IdentityType.APPLICATION) > public class Name implements Serializable, IName { > @PrimaryKey > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) > private Key key; > > @Persistent > private String firstName; > > @Persistent > private String lastName; > > @Persistent > private Date dob; > > //..... more properties > > @Persistent > private Key address; > > //... implememation - getters, setters, etc. > } > > Now as can be seen I am storing address as unowned relationship as a > key. This is important as a name can change address, and an address > may be shared by many names, hence my decision to make it unknown. > > The address class is simple, here is a snippet below: > > @SuppressWarnings("serial") > @PersistenceCapable(identityType = IdentityType.APPLICATION) > public class Address implements Serializable, IAddress { > @PrimaryKey > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) > private Key key; > > @Persistent > private String houseAndStreet; > > @Persistent > private String town; > > @Persistent > private String state; > > // etc. > } > > Now, in my UI I want to show a table with all the names and their > addresses in a single view (i.e. with columns firstName, lastName, > dob, houseAndStreet, Town, etc.) > > What is the easist way to do this? Sure I can get the names in 1 query > but then I don't have the addresses - only the key. Should I query > each one? Or should I get the entire address table and then sort it > out myself in memory? > > Please advise on the best approach and one that will perform best. > Maybe I've missed something obvious! > > Thanks, > fb > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-appengine%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-appengine?hl=en. > > -- *Jeff Schwartz* -- You received this message because you are subscribed to the Google Groups "Google App Engine" 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?hl=en.
