As the subject says I want to map a HashMap with a List as a value in Hibernate. Since it looks like it is not possible to have a collection as element in a map in Hibernate, I have created a class that contains a list of Ids.
My HashMap looks like this:
Map<Status, IdList> statusIdsMap = new HashMap<Status, IdList>();
Status is either insert/update/remove. IdList contains a List of Ids.
Hibernate mapping looks like this:
<id name="id" type="IdType" />
...
<map name="statusIdMap">
<key column="id" />
<map-key type="Status" column="StatusCode" />
<element type="IdList" />
</map>
...
<class name="IdList" select-before-update="true" table="IdList">
<id name="id" column="id" unsaved-value="null">
<generator class="IdGenerator"/>
</id>
<set name="Ids" table="IdsForStatus">
<key column="id"/>
<element column="updatedId" type="IdType"/>
</set>
</class>
If I try to store the class with statusIdMap, Hibernate generates an Insert SQL that tries to put the IdList class in a column, instead of the Id to the IdList class. The Hibernate error message says "expected number, got binary".
It's related question to this Hibernate(JPA) mapping a HashMap where the answer suggests to put list in the Key class, but it's not something I wish to do.
Any other suggestions?
EDIT: In short the test does following:
Fills object with dummy values, including map.
Initializing hibernate and starts a transaction
Inserts object
Commits transaction and closes hibernate session
The error message comes from the database when trying to commit, since the generated insert statement is wrong as mentioned above.