|
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:[EMAIL PROTECTED] 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 <[EMAIL PROTECTED]>
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 |
- RE: Using new Abator generated criteria and example Rashmi Dixit
