Hi
Could you help me figure out what I've made wrong.. I am reworking the using HQL to Criteria
I have query that worked fine by using HQL
Code:
"SELECT * from nurses order by (CASE type WHEN 'doctor' THEN 'arts' WHEN 'nurse' THEN 'zuster' ELSE 'Zzz' END) "
but when I try to something like that by criteria it doesn't work ...one of the attempt
Code:
hsession.createCriteria(Nurses.class).criteria.setProjection(Projections.sqlProjection("(CASE type WHEN 'doctor' THEN 'arts' WHEN 'nurse' THEN 'zuster' ELSE 'Zzz' END) as type_", new String[] { "type_" }, new Type[] { Hibernate.STRING })).addOrder(Order.asc("type_")).list()
it's thrown me the exception
org.hibernate.QueryException: could not resolve property: type_ of: ....
if I use the code like that
Code:
hsession.createCriteria(Nurses.class).addOrder(Order.asc("(CASE type WHEN 'doctor' THEN 'arts' WHEN 'nurse' THEN 'zuster' ELSE 'Zzz' END)")).list()
i have org.hibernate.QueryException: could not resolve property: (CASE type WHEN 'doctor' THEN 'arts' WHEN 'nurse' THEN 'zuster' ELSE 'Zzz' END) of:
P.S. I use Hibernate-Version: 3.2.1.ga
thanks in advance