I need to compare fields from 2 different tables using Hibernate queries.
Table A has a field which consists of sectionId(eg 1900).
Table B has a field which consists of userId/sectionId(eg e1230-12w11-3ewq-qg22-34qa/1900).
I need to extract sectionId from table B and compare it with sectionId in table A so that I can build a row for a new table. I also need to extract userId from table B and use it as a part of this new row too.
Does hql have the ability to compare fields partially?
I think you can do this using JPQL functions: SUBSTRING and LOCATE.
LOCATE will be able to locate the particular character in your input string and will return it's place.
Then you should be able to use SUBSTRING to return just a part of the string based on the index returned by LOCATE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With