简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM