Class with Maps
public class Page {
private Map<LocaleWrapper, String> titles;
private Map<LocaleWrapper, String> texts;
(...)
}
Key class
public class LocaleWrapper implements Serializable {
private Locale locale;
//Constructor, getter, setter
}
My IDE throws an error:
Basic attributes can only be of the following types: (...), or any Serializable type.
Why does my IDE throw this error and how can I fix my mappings?
Thanks in advance.
This error, AFAIK, is displayed because the attribute is inside a JPA entity, and not just a simple class.
And Map is not serializable.
Do you really want to save the whole map as a serialized byte array, in a BLOB column? If so, choose a serializable type, like HashMap. If not, then the map needs to define some form of association between entities and/or embedded types, and I would first think about how you want to store the information in the database, and map the database schema to entities.