Search in embedded Map stored as Jsonb

Hello,

I have the task to store & search translations of a text for different locales in a single DB-column.
To accomplish this i want use something like this:

@JdbcTypeCode(SqlTypes.JSON) 
Map<Locale, String> text;

in my Entity. The storage works fine, but afaik there is no way to create a Query that filters on these map keys and values like this:

SELECT s FROM MyEntity WHERE s.text.key = :locale AND s.text.value LIKE :searchString

I found this related topic, but this was created for older hibernate versions.
Are there any new features added in hibernate 6.2 to search in embedded JSON-Maps?

If not the only workaround i found would mean to create an embeddable Pojo like this:

@Embeddable
public class Translation {   
    String de;
    String en;
    String fr;
}

and let the entity-property be like this:

@JdbcTypeCode(SqlTypes.JSON) 
Translation text;

and search with a query like

SELECT s FROM MyEntity s WHERE s.text.de LIKE :searchString

Of course that would have several drawbacks like hard-coded locales, etc.

Even though you’d have to list all possible translations as fields, only the actual translations would be stored, so I don’t think it is so bad. There are no functions yet to query the JSON, but you can follow JSON functions · hibernate/hibernate-orm · Discussion #5900 · GitHub for updates.