Hi all,
is it possible to use named parmeters also for the property names?
In this case I used ":show" to represent showPPO property of the POJO. When I execute the code no errors are returned but the list I get is empty. If I remove ":show" and put p.showPPO than I get a filled list.
Hibernate version: 2.1.8
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Code:
String queryString = "from Promotion p where :date between p.startDate AND p.endDate AND p.status = :status"
+ " AND (:show like :id1 OR :show like :id2 OR :show like :id3 OR p.showPPO like 'message.promotion.show.all' OR p.showto like 'message.promotion.showto.both')";
Query hqlQuery = session.createQuery(queryString).setDate("date", new Date()).setString("status", "message.promotion.state.active");
hqlQuery.setString("show", "p.showPPO");
hqlQuery.setString("id1", String.valueOf(user.getWorkmate().getPpoId() + ",%"));
hqlQuery.setString("id2", "%," + String.valueOf(user.getWorkmate().getPpoId() + ",%"));
hqlQuery.setString("id3", "%," + String.valueOf(user.getWorkmate().getPpoId()));
Full stack trace of any exception that occurs: No errors
Name and version of the database you are using: Oracle 9i
The generated SQL (show_sql=true):
from Promotion p where :date between p.startDate AND p.endDate AND p.status = :status AND (:show like :id1 OR :show like :id2 OR :show like :id3 OR p.showPPO like 'message.promotion.show.all' OR p.showto like 'message.promotion.showto.both')
Debug level Hibernate log excerpt: