I have a question concerning the upgrade from hibernate 2.1.8 to 3.1.2 with respect to the binding of named parameters.
I have a query of the following form in my java code:
Query q =
session.createQuery(
"select cat from foo.Cat cat, foo.CatList catList" +
"where catList.id=:listId and catList.cats[:listPosition] = cat"
}
q.setInteger("listPosition", position);
q.setLong("listId", id.longValue());
return (Cat) q.uniqueResult()
There is a many-to-many relationship between CatList and Cat (CatList is a list of Cat objects)
This code used to work in v2.1.8 but fails with 3.1.2.
I have turned on show_sql in my hibernate.cfg.xml file and have verified the sql generated is correct. I then replaced the named parameters with the actual values and the code worked perfectly. It appears that the problem is related to the binding of named parameters.
I tried binding named parameters in simple situations e.g. catList.id=:id, which works fine. Perhaps there is a bug in the binding of named parameters when it comes to list indices?
Thank you in advance.
Yuan Chang
|