db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter S. Hamlen" <pham...@mail.com>
Subject RE: Cann't use criteria two times.
Date Thu, 13 Feb 2003 14:50:36 GMT
Vinod,

Although you don't give details of what the error message was, I'm going
to guess at the root cause. 

When you execute a doSelect() method using a Criteria, the Criteria is
actually modified to have the correct "select columns" in order to
create the appropriate objects (ie, a TurbineProject if you're calling
the TurbineProjectPeer).  If you then use the criteria a second time on
a different table, then it will have "extra" select columns and things
will break.

You can reuse a Criteria, so long as you use the Criteria against the
same table each time.  

In your particular case (as was mentioned elsewhere), I would simply
factor those "addJoin" lines into a method somewhere and call that to
get a new Criteria each time.

-Peter

On Thu, 2003-02-13 at 01:30, Vinod_Thapliyal wrote:
> 
> Thanks it worked. But, I thought that orque should be flexible enough to allow me to
use my  criteria again. It makes a bit tedious to rewrite the same code that u have already
written.
> 
> 
> 
> -----Original Message-----
> From: Jean-Marc Lavoie [mailto:jeanmarc.lavoie@videotron.ca] 
> Sent: Thursday, February 13, 2003 11:27 AM
> To: Turbine Torque Users List
> Subject: Re: Cann't use criteria two times.
> 
> The Criteria object is modified so the BasePeer can add some Cirteria of 
> is's own, like the field requested by the object. It look like it mix up 
> the BasePeer to reuse it. There was some discussion on that some weeks ago.
> 
> Simply create a new one, that make some line of code more, but  it will 
> work.
> 
> Good luck
> 
> Vinod_Thapliyal wrote:
> 
> > Hi all,
> >
> >I have created a criteria to query on one of my table. It involves join on tables.
The first time I query on a table the results are returned. But, next time when I try to use
the same criteria on the other table. It retunrs me an error. I tried a query on the second
table by commenting the query for first table then I get the results. But, the two queries
don't work together.
> >
> >The criteria is:
> >
> >criteria.addJoin(TurbineProjectsPeer.GROUP_ID,TurbineUserGroupRolePeer.GROUP_ID);
> >
> >                        criteria.addJoin(TurbineUserGroupRolePeer.GROUP_ID,TurbineGroupPeer.GROUP_ID);
> >
> >                        criteria.addJoin(TurbineUserGroupRolePeer.USER_ID,TurbineUserPeer.USER_ID);
> >
> > 
> >
> >                        criteria.add(TurbineUserGroupRolePeer.ROLE_ID,10);
> >
> >
> >                       Iterator = Projects;
> >
> > 
> >
> >Projects = TurbineProjectsPeer.doSelect(criteria).iterator();
> >
> > 
> >
> >                                    Projects = TurbineUserGroupRolePeer.doSelect(criteria).iterator();
> >
> >I get the following error:
> >
> >Error: org.apache.torqueException: Bad Conversion: java.lang.numberformatexception:
silent
> >
> >
> >Any clue why its behaving like this?
> >
> >vinod
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> >For additional commands, e-mail: torque-user-help@db.apache.org
> >
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 
> ---------------------------------------------------------------------
> 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