• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate criteria search problem

Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm using the Criteria api for building queries. Now I have bumped into
a sorting problem.

My Item class has a price and a discount. The Item class has a many to one relation with a Collection class. The Collection class also has a discount.

The Items discount superseeds the collection discount.
So when getting the discount in my class I use

discount > collection.discount ? discount : collection.discount

My problem no is sorting on price. I want to sort on

price - the item discount if larger then collection discount else collection discount multiplied by the price

My problem is that I can't this to work in my criteria. Any pointers?
[ May 21, 2008: Message edited by: Mathias Nilsson ]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic