I am wondering if it is possible using annotations to persist the attributes map in the following class using JPA2
public class Example {
long id;
// ....
Map<String, String> attributes = new HashMap<String, String>();
// ....
}
As we already have a pre existing production database, so ideally the values of attributes could map to the following existing table:
create table example_attributes {
example_id bigint,
name varchar(100),
value varchar(100));
JPA 2.0 supports collections of primitives through the
@ElementCollectionannotation that you can use in conjunction with the support ofjava.util.Mapcollections.Something like this should work:
See also (in the JPA 2.0 specification)