Thursday, 21 January 2016

XML : Hibernate Query: Using CASE After WHERE clause. Is this possible?

Is this query possible in Hibernate?

   SELECT           hm1.id     FROM           hibernateModel hm1     WHERE           current_date > hm1.expiryDate + (SELECT cast(hm2.code as int)     FROM           hibernateModel hm2     WHERE           hm2.type2 =     CASE           WHEN hm1.type1 = 'data1'  THEN 'changeData1'           WHEN hm1.type1 = 'data2'  THEN 'changeData2'           ELSE hm1.type1           AS type)      

The part WHERE = to CASE is the part I am not sure if this will work. Is this possible?

I am going to use this in java spring batch using a hibernateItemReader in xml.

It will be a great help if you can give me some advice.

Thank you in advance.

No comments:

Post a Comment