You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Robert Bowen <sy...@yahoo.com> on 2005/03/17 17:08:06 UTC

How to use doSelectJoin?

Hello all.

I would like to use doSelectJoin to populate some sub
objects. Here is the scenario:

TABLE user
pk id_user
...

TABLE profile
pk id_profile
...

TABLE users_profiles
fk id_user
fk id_profile

ie. all users can have n profiles.

When the user logs in I would like to load all of his
associated "users_profiles" objects *and* all of the
"profile" objects associated with those (to have
access to the name of the profile). Since I stick the
"user" object in my session, and later on make many
checks on the profile that user has, I would like not
to have to keep calling the database from my .jsp's.

I have been looking at
BaseUsersProfilesPeer.doSelectJoinProfiles, which
seems to load all the "profiles" associated with any
"users_profiles", but I don't see anything similar in
my BaseUserPeer class.

I guess that's the way Torque works -- it generates
these doSelectJoinXxx() methods for the tables which
contain foreign keys TO them FROM other tables. 

So how can I do the same thing for "user", which has a
foreign key TO "users_profiles"?

I'll keep looking!

Thanks,
Bob

ps. I have heard Hibernate does this "full-load" by
default, ie. it automatically loads all info for any
foreign keys. Is this true? Sounds nice but expensive!



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 

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


Re: How to use doSelectJoin?

Posted by Dave Newton <ne...@pingsite.com>.
Robert Bowen wrote:

>So how can I do the same thing for "user", which has a
>foreign key TO "users_profiles"?
>  
>
Isn't there a protected method in the base user that does the join? In 
the generated javadocs for your OM it should say something like "this 
isn't exposed to keep the API reasonable" or something like that.

You need to expose the method in your user class (the one for 
implementing custom functionality) and you should be all set.

Dave



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