I have tried with List and Map, but I cannot figure out how to force Hibernate 3.6.4 to persist null values in those collections. This is what I've tried:
@ElementCollection(fetch=FetchType.EAGER)
@Column(columnDefinition="longtext")
private Map<Integer, String> parameterValues;
and
@ElementCollection(fetch=FetchType.EAGER)
@OrderColumn
@Lob @Column(length=65535)
private List<String> parameterValues;
If the Map or List contains a null value, Hibernate does not persist it in a row in the collection table. When the collection is retrieved from the database, it has fewer elements than when it was stored because those that are null are not restored. The List restored null values for indices between the first and last indices with non-null values, but any null values at the end of the list were left out. The Map only contained entries for non-null values.
I hope this is making sense. It seems like a bug in Hibernate to me, but I'm hoping it's something I can fix with a different configuration.