My application uses JPA to access the backend database.
I have a Java class mapped to a table. The class has a string field (called status) that consists of a series of “0”s and “1”s. I need to select a few records based on the field’s second character. Here is what I can do without using JPA (I am using MS SQLServer).
SELECT * FROM Machines where SUBSTRING(status, 2, 1) = '1'
How can I do it using JPA?
There is a SUBSTRING function in JPA:
http://download.oracle.com/otn-pub/jcp/persistence-2.0-fr-eval-oth-JSpec/persistence-2_0-final-spec.pdf
4.6.17.2.1 “String functions”