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 Vinod_Thapliyal <Vi...@infosys.com> on 2003/02/13 06:56:30 UTC

Cann't use criteria two times.

 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

Re: Cann't use criteria two times.

Posted by Jean-Marc Lavoie <je...@videotron.ca>.
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
>
>