ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rashmi Dixit" <rash...@gmail.com>
Subject RE: Using new Abator generated criteria and example
Date Mon, 28 Aug 2006 14:50:38 GMT
Thanks, Jeff. Will you consider adding this clear method to Abator
generated example itself? If not, any reasons why?

 

Regards

~Rashmi 

 

  _____  

From: Jeff Butler [mailto:jeffgbutler@gmail.com] 
Sent: Saturday, August 26, 2006 8:07 PM
To: user-java@ibatis.apache.org
Subject: Re: Using new Abator generated criteria and example

 

Yes - I expected that you would create a new example class for each
query in this situation.  This is pretty small overhead as nothing else
is being cached.  But that's easily changed - you could add a method to
the example class that simply clears the list of criteria objects. 

 

Jeff Butler

 

On 8/25/06, Rashmi Dixit <rashmid@gmail.com> wrote: 

Hi Jeff,

 

We have just upgraded to use the latest abator and iBATIS. We have a
scenario as:

-          Get all users from a table - USERS

-          For each user, find some information from another table

 

What we did with the old Abator was:

-          Create a UserProfileExample object.

-          Set the user_id indicator in the example object

-          For each user in the given list do the following

o        Set the user_id field in the UserProfileExample with the
required value for which information needs to be retrieved. 

o        Fire the select using the required DAO 

o        Obtain required information and do something

 

The new Abator introduces the criteria object for the example class. We
tried to fit this into the loop written earlier. Below is what we have
needed to do: 

-          UserProfileExample userProfileExample=new
UserProfileExample();

-          Criteria criteria=userProfileExample.createCriteria();

-          For each user in the given list do the following 

o        ==> if(criteria.getCriteriaWithSingleValue().size()>0)
criteria.getCriteriaWithSingleValue().remove(0); 

o        criteria.andUserIdEqualTo(userID);

o        Fire the select using the required DAO 

o        Obtain required information and do something

 

There is only a way to add a criterion to an example object, no way to
remove/change it. Perhaps the design means us to create a new example
for each new query fired? 

 

However, my query is something like a parameterized query where I simply
need to change the value of the parameter and fire the query again. I do
not like the fact that I need to reach into the internals of the
criteria object and remove elements from the list that it maintains (
==> ). 

 

Can you suggest a better way to do the same? 

 

Regards

~Rashmi

 


Mime
View raw message