For example Customer
has a field of type PhoneNumber
(value object).
In the persistence.xml
a PhoneNumberConverter
is registered which implements javax.persistence.AttributeConverter
. This converter converts a PhoneNumber
to string and visa versa, so the JPA provider is able to store PhoneNumbers
into the database.
How to query a Customer
with a LIKE
operator on PhoneNumber
with the Criteria API? PhoneNumber
can only be a valid phone number. A PhoneNumber
with a value like '+31%'
is not possible.
The simple answer is to use a
NamedQuery
, but you could also use aCriteriaBuilder
. Note that you will have to provide the correct types and search terms.Something like this: