-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Expression.like being ignored.
PostPosted: Tue Nov 16, 2004 7:11 pm 
Newbie

Joined: Tue Nov 16, 2004 6:52 pm
Posts: 3
Hi,

My database is mysql4.1.1, when I query it with just one 'like' expression, it works fine, eg:

Criteria criteria = session.createCriteria(npd.hibernate.Plant.class);
criteria.add( Expression.like("genus", plantForm.getGenus() +"%" ));
list = criteria.list();

The sql that's generated is:
Hibernate: select this.id as id0_, this.active as active0_, this.genus as genus0_, this.species as species0_ from plant this where this.genus like ? order by this.genus asc, this.species asc
(where the parameter is 'a%')


But when I add another 'like' expression, the criteria is ignored altogether and I get the entire database back, eg:

Criteria criteria = session.createCriteria(npd.hibernate.Plant.class);
criteria.add( Expression.like("genus", plantForm.getGenus() +"%" ));
criteria.add( Expression.like("species", plantForm.getSpecies() + "%"));
list = criteria.list();

The sql that's generated is:
Hibernate: select this.id as id0_, this.active as active0_, this.genus as genus0_, this.species as species0_ from plant this where this.genus like ? and this.species like ? order by this.genus asc, this.species asc
(where the parameters are 'a%' and 'a%')

The generated sql works just fine against the database.

Thank you, any assistance would be greatly appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 29, 2004 11:01 pm 
Newbie

Joined: Tue Nov 16, 2004 6:52 pm
Posts: 3
In case anyone is interested. I replaced the MySql database with a Hsqldb database, the queries (as well as inserts, updates and deletes) now work perfectly.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.