I want to use (searchable) localization in my models, and i came up with the following model:
@Entity
public class Category {
...
@ElementCollection
//key = language code (e.g. 'en') and value = localized label
private Map<String, String> name;
...
}
What I want to do no is to query for categories which contain an caseinsensitive needle in a particular localization (e.g. with '%abc%' in their english name)
I tried something like
from Category where name.key = :locale and lower(name.value) like :text
but that fails with a cannot dereference scalar collection element exception.
Now the hibernate docu says, i have to use elements() and indices() for values and keys. For the key this would be easy using :locale in indices(name)
, but how can i then match a part of the value of this locale in an caseinsensitive manner?
And just in case this is not doable with hql with my model, how else could i model searchable localization?