I have a class like this:
class MyEntity {
@ElementCollection
Map<String, String> properties;
}
I’d like to find out which MyEntity entities have a property value that matches like query using the criteria API. By this I mean I’d like to make a like query on the values of the map entries.
For example if one of my MyEntity classes has a property named “email” and the value is “example@mail.com”, how do I make a query that finds the entity with a query parameter “example%” using criteria API?
Okay, I found a solution. There is a joinMap(String) method in Path API which can be used in this case:
That piece of code will create a
likepredicate against the values of the properties map. This would probably been easier to find out if I had generated the MetaModel of the MyEntity…