Make sure that the Spring configuration for the example class is set to
"prototype" scope, and not the default "singleton".  The example classes are
not designed for reuse - a new one should be created for each query.

Alternatively, you could create the example class directly - I don't think
Spring is really buying you any function here:

PeopleExample peopleExample = new PeopleExample();
peopleExample.createCriteria().andPeople_idEqualTo("0008");
List<People> peoples=peopleDAO.selectByExample(peopleExample);


Jeff Butler


On 2/1/07, Allan Kamau <[EMAIL PROTECTED]> wrote:

I am unable to reduce (by filteration) the returned query results using
the example class and it's Criteria object.
I have generated ibatis classes and the sql map file(s) using Abator
having "generatorSet" attribute of the <abatorContext> configuration element
set to 'Java5'.

The code (using spring) below returns all the entries in the database
without applying the filter. A manually written select query for
people_id='0008' returns a subset of the rows in the table.

/**Client code section of query using the example class **/
       PeopleExample
peopleExample=(PeopleExample)context.getBean("peopleExample");
       PeopleExample.Criteria criteria=peopleExample.createCriteria();
       criteria.andPeople_idEqualTo("0008");

       List<People> peoples=peopleDAO.selectByExample(peopleExample);
       for(Iterator<People> i=peoples.iterator();i.hasNext();)
       {
           people=i.next();
           System.out.println(people.getPeople_id_key());
       }

This code below works as expected, it only correctly applies the filter
/**Client codelet issuing a query directly via the Dao object **/
       String s_l_p_p_v_i=null;People people=null;
       for (int i=0; i < 1; i++) {
           //peopleDao.getByNameAndRunDate("foo", today);
           people=peopleDAO.selectByPrimaryKey(new Long(404));
           System.out.println(people.getPeople_id_key());
       }


Where can I be going wrong?

Allan.







____________________________________________________________________________________
Never Miss an Email
Stay connected with Yahoo! Mail on your mobile.  Get started!
http://mobile.yahoo.com/services?promote=mail

Reply via email to