I am running Hibernate 3.1.3 and have the following issue:
I have an Entity-Class called
'Data' which holds/assiciates a Collection of
Event-Objects.
'Data' is a 'complete' Class representing a table and its columns.
'Event' s a Class representing a relation table between Table_Data and Table_Event and has no own primary key.
Here aa extract of Data.hbm.xml:
Code:
<set
name="historySet"
table="Table_Data_Event"
lazy="false"
cascade="all-delete-orphan"
sort="unsorted"
order-by="data_ID, event_ID"
>
<key
column="data_ID"
>
</key>
<many-to-many
class="com.company.project.model.Event"
column="event_ID"
outer-join="auto"
/>
</set>
Here Event.hbm.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="com.company.project.model.Event"
table="Table_Event"
>
<id
name="id"
column="event_ID"
type="java.lang.Integer"
>
<generator class="identity">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Event.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="date"
type="java.util.Date"
update="true"
insert="true"
column="eventDate"
/>
<property
name="description"
type="java.lang.String"
update="true"
insert="true"
column="description"
/>
<many-to-one
name="employee"
class="com.company.project.model.Employee"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="employee"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Event.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
I thought Hibernate saves
Event objects too, when I save a
Data object (since the
Event objects are within a Set member of
Data) but exactly this does not happen.
What am I doing wrong or what do I forget to do?
Thank you
du-it