You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Laurie Harper <zo...@holoweb.net> on 2004/03/31 07:28:42 UTC

Foreign key lookups

I never did get a conclusive answer on this, so I'm reposting with more 
background.

What I was hoping to be able to do is something like this:

   Player p = getPlayer();
   OQLQuery query = odmg.newQuery();
   query.create("select all from " + Team.class.getName() +
                " where player = $1");
   query.bind(p);
   query.execute();

Unfortunately, that results in an error because Player is not 
serializable. If I modify the code like this everything is fine:

   query.create("select all from " + Team.class.getName() +
                " where PLAYER_ID = $1");
   query.bind(new Integer(p.getID());

The only problem is that the ID property on Player is set up using 
anonymous access... I want to minimize the number of database artifacts 
I add into my object model and, since the integer PK columns in the 
database exist for join performance rather than semantic relevance to 
the object model, they're something I'd rather not expose through the 
java APIs.

So, my first question is should what I tried first work? OJB has the 
information it needs to implement support for this (from the repository 
descriptor) but is it outside the ODMG specification?

Second question is, if I can't do what I first tried, can I use 
OJB-specific APIs to work around the OQL limitation? This is more for 
interest, since if I have a choice between 'cluttering' my object model 
and breaking compliance with ODMG, I'll choose the former. I just want 
to know if those really are my only choices...

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org