Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • 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
Hi!

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 ]
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!