Skip to main content
Question Protected by cassiomolin
Replaced `order` tag with `sql-order-by`.
Link
gnerkus
  • 12.2k
  • 7
  • 54
  • 76
Grammar; noise reduction.
Source Link
Mogsdad
  • 46k
  • 21
  • 166
  • 289

When I write a HQL query

Query q = session.createQuery("SELECT cat from Cat as cat ORDER BY cat.mother.kind.value"); return q.list(); 

Everything is fine. However, when I write a Criteria

Criteria c = session.createCriteria(Cat.class); c.addOrder(Order.asc("mother.kind.value")); return c.list(); 

I get an exception org.hibernate.QueryException: could not resolve property: kind.value of: my.sample.data.entities.Cat

If I want to use Criteria and Order, how should I express my "order by"?

Cheers

Nik

When I write a HQL query

Query q = session.createQuery("SELECT cat from Cat as cat ORDER BY cat.mother.kind.value"); return q.list(); 

Everything is fine. However, when I write a Criteria

Criteria c = session.createCriteria(Cat.class); c.addOrder(Order.asc("mother.kind.value")); return c.list(); 

I get an exception org.hibernate.QueryException: could not resolve property: kind.value of: my.sample.data.entities.Cat

If I want to use Criteria and Order, how should I express my "order by"?

Cheers

Nik

When I write a HQL query

Query q = session.createQuery("SELECT cat from Cat as cat ORDER BY cat.mother.kind.value"); return q.list(); 

Everything is fine. However, when I write a Criteria

Criteria c = session.createCriteria(Cat.class); c.addOrder(Order.asc("mother.kind.value")); return c.list(); 

I get an exception org.hibernate.QueryException: could not resolve property: kind.value of: my.sample.data.entities.Cat

If I want to use Criteria and Order, how should I express my "order by"?

Tags do not belong in titles
Link
Justin Johnson
  • 31.4k
  • 7
  • 67
  • 89

Hibernate: ORDER BY using Criteria API

Source Link
niklassaers
  • 8.9k
  • 21
  • 105
  • 158
Loading