I just tried to switch from Hibernate 3.0 RC1 using the classic parser to Hibernate 3.0 final with the new parser. I haven't used the new parser yet because of a problem with correlated subqueries, which is now supposed to be fixed.
I recognized that my code, which works just fine with the classic parser (Hibernate 3 RC1 and final), doesn't work using the new parser. Find the code, the SQL output and the exception below.
Thanks for your help!
Best regards
Sven
Hibernate version: 3.0 final
Name and version of the database you are using: MySQL 4.0.24
code
Code:
final StringBuffer buffer = new StringBuffer(300)
.append("SELECT order FROM Order AS order WHERE ")
.append("order.aNode LIKE :aNode AND ")
.append("order.customer LIKE :customer AND ")
.append("order.orderName LIKE :orderName AND ")
.append("order.responsiblePersonExternal LIKE :rpext AND ")
.append("order.responsiblePersonInternal LIKE :rpint ")
.append("ORDER BY order.aNode DESC ")
.append("LIMIT 0, :maxResultCount");
final Session session = HibernateUtil.getSession();
final Query query = session.createQuery(buffer.toString());
query.setString("aNode", "%" + aNode + "%");
query.setString("orderName", "%" + orderName + "%");
query.setString("customer", "%" + customer + "%");
query.setString("rpint", "%" + rpInt + "%");
query.setString("rpext", "%" + rpExt + "%");
query.setInteger("maxResultCount", maxResultCount + 1);
final List result = query.list();
output using the classic parserCode:
Hibernate: select order0_.id as id, order0_.anode as anode0_, order0_.ordername as ordername0_, order0_.customer as customer0_, order0_.rpe as rpe0_, order0_.rpi as rpi0_ from aorder order0_ where (order0_.anode LIKE ? )AND(order0_.customer LIKE ? )AND(order0_.ordername LIKE ? )AND(order0_.rpe LIKE ? )AND(order0_.rpi LIKE ? ) order by order0_.anode DESC LIMIT 0 , ?
exception using the new parserCode:
org.hibernate.QueryException: Named parameter does not appear in Query: maxResultCount [SELECT order FROM de.company.project.persistence.Order AS order WHERE order.aNode LIKE :aNode AND order.customer LIKE :customer AND order.orderName LIKE :orderName AND order.responsiblePersonExternal LIKE :rpext AND order.responsiblePersonInternal LIKE :rpint ORDER BY order.aNode DESC LIMIT 0, :maxResultCount]
output using the new parserCode:
Hibernate: select order0_.id as id, order0_.anode as anode0_, order0_.ordername as ordername0_, order0_.customer as customer0_, order0_.rpe as rpe0_, order0_.rpi as rpi0_ from aorder order0_ where ((order0_.anode like ?) and (order0_.customer like ?) and (order0_.ordername like ?) and (order0_.rpe like ?) and (order0_.rpi like ?)) order by order0_.anode DESC