db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Bowen <s...@yahoo.com>
Subject Re: How to use doSelectJoin?
Date Fri, 18 Mar 2005 12:05:54 GMT
I should have done more testing before posting. It
turns out what I was most worried about was Torque
calling the database every time I looked up the
profiles associated with the user. But since the User
object will be in session, it will only call the
database the first time. After that it will be cached.


So in the end, I really don't have any problem!

Thanks for your quick and helpful responses.

Bob

--- Thomas Fischer <fischer@seitenbau.net> wrote:
> 
> 
> 
> 
> Robert,
> 
> I do not see a possibility to load all your datasets
> using one single join
> if you only use pregenerated classes. But if you
> only want to get the stuff
> from the db and do not care whether it is a single
> sql statement or not,
> you can use the following PSEUDOcode:
> 
> User user = UserPeer.doSelect(userCriteria);
> // following loads and caches the userProfiles
> within the user
> List userProfiles = user.getUserProfiles();
> // now load the profiles
> foreach (userProfile in UserProfiles) {
>   // load and cache the associated profile
>   userProfile.getProfile();
> }
> // now the user has associated all its profiles
> // If you call user.getUserProfiles() again, the
> user object will not ask
> the db again,
> // but use the cached objects instead
> 
> If you want the call to be a single statement
> because of transaction
> safety, you can also wrap the above in a
> Transaction.start() and
> Tranaction.commit() wrapper.
> 
> Sure this is not the most performant solution of
> all, but it works ;-). I
> use it every time I am in such a situation.
> 
>   Thomas
> 
> 
> Robert Bowen <syg6@yahoo.com> schrieb am 17.03.2005
> 19:32:48:
> 
> > Hello, thanks for the response.
> >
> > Yea, "doSelectJoinXxxx()" is a protected method
> > generated by Torque but in my particular
> situation,
> > this method is not being generated for the object
> I
> > need.
> >
> > There is a doSelectJoinProfiles() in the
> > BaseUsersProfilesPeer class, which will load all
> the
> > info for all profiles associated with any
> > UsersProfiles object, but there is no
> > "doSelectJoinUsersProfiles()" method in my
> > BaseUserPeer class, and this is what I need -- to
> > first load all UsersProfiles associated with a
> given
> > user, and then load all of the Profiles themselvs
> > (specifically what I need is the profile name).
> >
> > Any other takers?
> >
> > Bob
> >
> > --- Dave Newton <newton@pingsite.com> wrote:
> > > 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
> 
> 


		
__________________________________ 
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


Mime
View raw message