I want to achieve the effect of following query in Hibernate, but I'm unable to figure out a way to do this.
select e.TITLE from EVENTS e where e.TITLE REGEXP 'fri|pro';
Can someone help?
Hibernate QL doesn't support regular expressions (and some engines have a very poor regexes support). You can transform your query to be
select e.TITLE from EVENTS e where (e.TITLE = 'fri' OR e.TITLE = 'pro');
or
select e.TITLE from EVENTS e where e.TITLE in ('fri','pro');
But for real regex support you'll have to write custom SQL (if your DB does support regexes at all)
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