ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Allan Kamau <kamaual...@yahoo.com>
Subject Re: Unable to filter using Abator generated example class.
Date Fri, 02 Feb 2007 18:26:17 GMT
Thanks Jeff, after trying out many permutations in the abator config file and the generated
sqlmap (over several days) I thought may be the spring installation I was using was preceded
by the features (use of example class for queries) I was trying to use. I've just downloaded
the latest spring build (2.0.2) and then downloaded a number of dependences and it works (but
I still had to modify the sqlmap configuration file based on the complaints from com.ibatis.sqlmap.client.SqlMapException:
There is no statement named...).
This means that from my experience, spring 2.0 deployment will not make use of query filters
generated for the example class, an upgrade is recommended.

Allan.

----- Original Message ----
From: Jeff Butler <jeffgbutler@gmail.com>
To: user-java@ibatis.apache.org
Sent: Thursday, February 1, 2007 3:06:50 PM
Subject: Re: Unable to filter using Abator generated example class.

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 <kamauallan@yahoo.com> 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









 
____________________________________________________________________________________
Any questions? Get answers on any topic at www.Answers.yahoo.com.  Try it now.
Mime
View raw message