2

I have a table like below CODES(location, code, description, start_date, end_date)

I need the below query using Hibernate criteria or detached criteria

SELECT location, code, description, start_date, end_date FROM CODES WHERE (location,code) in (('loc1','1'),('loc2','2'),('loc3','3'),('loc4','4'),('loc5','5'))

I have to pass the location and code values as parameters(dynamically pass at run time).

How to get the above query using Hibernate criteria or detached criteria

user1645988
  • 33
  • 1
  • 5

1 Answers1

0

An equivalent expression in SQL is:

SELECT location, code, description, start_date, end_date 
FROM CODES 
WHERE (
    (location = 'loc1' AND code = '1') OR
    (location = 'loc2' AND code = '2') OR
    (location = 'loc3' AND code = '3') OR
    (location = 'loc4' AND code = '4') OR
    (location = 'loc5' AND code = '5')
)

You can follow this instructions to write the hibernate criteria.

Community
  • 1
  • 1
messivanio
  • 2,263
  • 18
  • 24