How do we write the equivalent of the following HQL as a criteria query?
HQL: "from Entity where prop1 = '1' and prop2 = 2"
CRITERIA: session.createCriteria(Entity.class) .add(Restrictions.eq("prop1",'1')) .add(Restrictions.eq("prop2",2))
These two are not the same, because the criteria query executes it as a prepared statement.
How do we force the HQL or criteria to not execute it as a prepared statement or return the equivalent SQL?
The goal is to be able to get the equivalent sql out of the criteria query, in cases such as "union" queries. Simple parameters can be appended directly, but custom hibernate types make it complicated. Why isn't there a simple way to get the equivalent SQL or for that matter no way to specify constants in a criteria query?
Thanks
|