Hello,
I'm a hibernate n00b, but an experienced Java developer. My problem occurs when saving an object with a HashMap into the database.
When I initially save the transient object, it inserts the object's data and cascades to the maps and other objects, but for some reason it never inserts any values in the link table (tk_sheet_to_row). It does save the map values to the proper tables, but the link tables remain empty.
What this means is that the object loses the references to the values. The values are there, but there's no link from the object to those values. If I do a save(), evict the object from the cache and reload the object, it has empty maps.
For some reason when later on I'm updating the object, the links are saved, but the initial save does not seem to cascade properly.
Any thoughts on this, or need for further information?
Hibernate version: 3.1
Mapping documents:
<hibernate-mapping default-lazy="false">
<class name="com.digitalchocolate.ddb.domain.toolkit.SheetImpl" table="tk_sheet">
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<discriminator/>
<timestamp name="version" column="hibernate_version" source="db"/>
<!--<version name="version" column="hibernate_version" type="timestamp"/> -->
<property name="parentId" column="parent_id" type="long"/>
<property name="name" type="string" not-null="true"/>
<property name="locked" type="boolean"/>
<property name="createStatics" type="boolean"/>
<property name="toolkitSheet" type="boolean"/>
<many-to-one name="comment" not-null="false" class="com.digitalchocolate.ddb.domain.common.CommentImpl" lazy="false" column="comment_id" cascade="persist,save-update,evict"/>
<map name="rowMap" table="tk_sheet_to_row" lazy="false" cascade="persist,save-update,evict">
<key column="rows_id"/>
<index column="row_name" type="string"/>
<many-to-many column="row_id" class="com.digitalchocolate.ddb.domain.toolkit.RowImpl"/>
</map>
<map name="columnMap" table="tk_sheet_to_column" lazy="false" cascade="persist,save-update,evict">
<key column="columns_id"/>
<index column="column_name" type="string"/>
<many-to-many column="column_id" class="com.digitalchocolate.ddb.domain.toolkit.ColumnImpl"/>
</map>
</class>
</hibernate-mapping>
Name and version of the database you are using:
MySQL 5.0.22
The generated SQL (show_sql=true):
Everything except inserts to link table.
|