Thanks, Rusty, for your insight. I think this will technically work, but I will have to kiss goodbye to database look-ups by key, which is a big loss. Key look-up is lightning fast compared to querying by index. If I separate accountId from id, then I'll have to GQL something like "select from Account where accountId=?" as opposed to pm.getObjectById(accountId).
I'm still hopeful about the composition approach. I just started coding. Let's see how it goes. Thanks, Yegor On Dec 13, 2:51 pm, Rusty Wright <[email protected]> wrote: > Another way you could look at is that by using things like customerId and > accountId as your database primary keys you're mixing your business stuff > with the database persistence stuff. If you create a primary key in the base > class and call it something like id, you can still have the accountId and > customerId in the subclasses. But ignore that database primary key (id) in > your business logic and only use it for database things. You still have and > can still use customerId and accountId in queries. Think of the database > primary key, id, as just some book keeping stuff, an implementation detail, > for the orm (datanucleus).Yegor wrote: > > Thanks for your reply. I guess that's what I will do in my next app. > > However, in the existing app the identity fields are already defined > > in the subclasses, and they have different names too, e.g. Account > > would have accountId, Customer would have customerId, so I cannot move > > the ID field to the root of the hierarchy as it will not map to the > > existing data in the App Engine Datastore. > > > This seems very strange. Ability to move common fields into a shared > > class seems like a very natural thing to do. I am surprised that it is > > not supported by Datanucleus. > > > That said, I haven't lost all hope. Maybe composition instead of > > inheritance can help. I am going to check if I can use embedded > > classes to solve this problem. > > > Yegor > > > On Dec 13, 1:54 am, datanucleus <[email protected]> wrote: > >> With all persistence standards, the identity field(s)/property(s) have > >> to be in the base persistent class. > > > -- > > > 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 > > athttp://groups.google.com/group/google-appengine-java?hl=en. -- 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.
