Hy,
just a question :
Why this Query is not correctly rendered by Hibernate ? :
String req = "select store.id, " +
" (select count(quantity) FROM TItems i_2 " +
" WHERE i_2.store.id = store.id" +
" AND i_2.recall.id = :id "
+ " AND i_2.quantity = 0), " +
" (select count(quantity) FROM TItems i_3 " +
" WHERE i_3.store.id = store.id" +
" AND i_3.recall.id = :id "
+ " AND i_3.quantity > 0), 1 "
+ "FROM TStore store "
+ "WHERE EXISTS ( select items.store.id "
+ " FROM TItems items "
+ " WHERE items.store.id = store.id"
+ " AND items.recall.id = :id )" ;
Query q;
List list;
// getting StoreGroupAndCount list.
q = HibernateUtils.getSession().createQuery(req);
q.setLong("id", recall.getId());
list = q.list();
I got :
select tstore0_.StoreID as col_0_0_ from v_Store tstore0_ where exists (select titems1_.StoreID from Recall_Article_Store titems1_ where titems1_.StoreID=tstore0_.StoreID and titems1_.RecallID=?)
!!!!
|