Announcement Announcement Module
Collapse
No announcement yet.
Convert SQL to Hibernate Criteria Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Convert SQL to Hibernate Criteria

    Hi Experts

    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.
    Please suggest.

    Thanks.....
    Ceezane

  • #2
    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(..).

    Joerg

    Comment

    Working...
    X