to give some background the app is to store student names in a school.
So you could have more than 1 students (typically siblings) living at
the same address. So if they move by having the address in its own
class, if they move you only need to change the address once and it
will all remain in sync too.

I guess I could have the Name class as an owned relationship in an
address, and have a set of them stored (i.e. more than 1). But that
breaks the potential situation where 2 students who previously lived
at the same address no longer do as you cannot break the Name object
out of its entity group. This is why I have unowned relationships.

I guess I could follow your suggestion and have my application make
sure addresses are synchronized, but its duplication of data which is
usually considered poor design.

Any other thoughts?

On Dec 3, 1:32 am, Jeff Schwartz <[email protected]> wrote:
> 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.

Reply via email to