I have this this kind of situation:
Code:
<class name="Item">
...
<map name="map" table="map_table">
<key column="FKitem"/>
<map-key column="locale" type="string"/>
<composite-element class="MapEntry">
<property name="description" column="description" type="string"/>
<property name="colour" column="colour" type="string"/>
</composite-element>
</map>
Ie, There is a class '
Item' that contains map '
map' with multilanguage map of some data.
This implies table structure to store map content:
Code:
map_table (FKitem integer, locale varchar, description varchar, colour varchar);
With this data in the table
Code:
(1, "pl", null, null),
(1, "en, "desc", "red")
hibernate does not create entry for key 'pl' in the map when I load an #1 instance of '
Item', because every property in '
MapEntry'is null.
Now, if I put some data into the map under the 'pl' key (which seem to be a new record from the point of view of the map, but remember that it already exists in db), hibernate issues '
insert' instead of '
update' clause. This leads to 'duplicate entry' error.
So my question is: how to force hibernate to create composite entries with all null properties? Maybe there is other way to handle such situations?
Basically I am interested in solutions for Hibernate 3.2.6.