Nov 30th, 2007, 12:29 AM
Convert SQL to Hibernate Criteria
My self Ceezane and I am a new member of this forum.
Will you pls help me to convert below mentioned SQL Query into Hibernate Criteria API.
select * from main_product_group_masterfile
where mpgcode in(select dfranmpg from dealer_franchise_file where dfrandid=330 and dfranmpg not in
(select mpg from mpg_restriction_file where dealer_id=330 and user_id='SEC'))
Actually, I want to use Criteria API for subquery.
Nov 30th, 2007, 09:23 PM
This depends on your mapping. SQL works on tables, Hibernate works on objects. Usually you don't have a one-to-one mapping between tables and objects. Besides that you find nearly every keyword also in Hibernate's criteria API. The way to us it is via the static methods in Restrictions class like in Restrictions.in(..) or Restrictions.not(..).