Search code examples
javasqlregexdatabasejpql

How to use regex in Java Persistence Query Language?


I'm using Java DB. I am trying to return records where the characters in the column contain the keyword, eg. Apple. Not 'pineapple' or 'appleton'. How can I do this?

I tried these with em.createNativeQuery(querystring)

SELECT e FROM Table e WHERE e.column REGEXP '[[:<:]]KEYWORD[[:>:]]'
SELECT e FROM Table e WHERE e.column REGEXP '.\\bKEYWORD\\b.'

java.sql.SQLSyntaxErrorException: Syntax error: Encountered "REGEXP" 

I also tried it with REGEXP_LIKE but the syntax error comes up again.

EDIT: EJBQL, the language that Java DB uses, does not support REGEX. I moved my database to mySQL.


Solution

  • EJBQL, the language that Java DB uses, does not support REGEX. I moved my database to mySQL.