I've got an entity that contains the following member attributes:
@Id
protected String id;
@ElementCollection(targetClass = String.class)
@MapKeyClass(String.class)
protected Map<String, String> data = new HashMap<String,String>();
This maps to two tables, an ENTITY table, and an ENTITY_DATA table which contains a row for each element in the HashMap. It maps the values in the HashMap as VARCHAR(256) and I need it to be VARCHAR(1024). Can this be done? I cannot find anything in the ElementCollection or MapKeyClass annotations that would allow for this.
Because, as you say, problem is with values, it goes as with columns in general. Just add following annotation to the field.
@Column(columnDefinition = "varchar(1024)")
With JPA 2.0 you can do same also to field where key of the map is persisted with MapKeyColumn annotation:
@MapKeyColumn(columnDefinition = "varchar(1024)")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With