change cascade="none" to cascade="save-update" or cascade="all"
zargarf wrote:
Hi
I'm having trouble, please help. I have a document object that contains a Set of Note Objects (a one to many relationship). Each object refers to the relevant table. However, when I edit the document object and add a new Note to the collection and try to update my changes, I get the following exception:
Hibernate Exceptionobject references an unsaved transient instance - save the transient instance before flushing: beans.Note
I need the new Note object in the collection to be saved along with any changes to the Document Bean object. Can anyone help me?
Cheers
Faisal
-----
My Mappings are:
1) DocumentBean
<hibernate-mapping>
<class name="beans.DocumentBean" table="document">
<id name="docId" unsaved-value="0" type="long">
<generator class="native" />
</id>
<property name="status" type="string" />
<property name="docType" type="string" />
<property name="fileName" type="string" />
<property name="lastModified" type="string" />
<property name="userId" column="memno" type="string" />
<property name="mimeType" type="string" />
<property name="fileContents" type="binary" />
<set name="notes" table="note" lazy="true" cascade="none">
<key>
<column name="docId" not-null="false" />
</key>
<one-to-many class="beans.Note" />
</set>
</class>
</hibernate-mapping>
2) Note
<hibernate-mapping>
<class name="beans.Note" table="note">
<id name="noteId" unsaved-value="0">
<generator class="native" />
</id>
<property name="text" />
<property name="username" column="username" />
</class>
</hibernate-mapping>