hi all,
I am having the exception :
net.sf.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: atchik.app.postcards.kernel.model.PostcardStatus
at net.sf.hibernate.impl.SessionImpl.throwTransientObjectException(SessionImpl.java:2764)
at net.sf.hibernate.impl.SessionImpl.getEntityIdentifierIfNotUnsaved(SessionImpl.java:2756)
at net.sf.hibernate.type.EntityType.getIdentifier(EntityType.java:66)
at net.sf.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:47)
My object are postcards and postcardStatus, a postcard contains a list of postcardStatus.
This exception happens when i load a stored postcard, add a postcardStatus to the list, and do a saveOrUpdate.
My mapping is :
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="atchik.app.postcards.kernel.manager.storage.impl.PostcardHibernateAdapter" table="Postcard">
<id name="databaseId" column="id" type="long" unsaved-value="null">
<generator class="native"/>
</id>
<property name="reference" column="reference" type="string" length="18" not-null="true"/>
<property name="status" column="status" type="int" not-null="true"/>
<property name="receptionDate" column="receptionDate" type="timestamp" not-null="true" />
<property name="originalText" column="originalText" type="text"/>
<property name="message" column="message" type="text"/>
<property name="aggregatePage" column="aggregatePage" type="int"/>
<component name="address" class="atchik.app.postcards.kernel.model.DeliveryAddress">
<property name="postcode" column="postcode" type="string" length="63" />
<property name="country" column="country" type="string" length="63" />
<property name="name" column="address" type="string" length="63" />
<property name="city" column="city" type="string" length="63" />
</component>
<!-- printedAddress property is mapped in PostcardHibernateAdapter -->
<property name="printedAddress" column="printedAddress" type="text" />
<property name="postcardUserId" column="userId" type="int" />
<property name="originalImageContentId" column="originalImageContentId" type="string" length="255" />
<property name="aggregateId" column="aggregateId" type="string" length="255" />
<property name="backContentId" column="backContentId" type="string" length="255" />
<property name="frontContentId" column="frontContentId" type="string" length="255" />
<list name="postcardStatus" table="PostcardStatus" cascade="all" >
<key column="postcardId"/>
<index column="status_number"/>
<one-to-many class="atchik.app.postcards.kernel.model.PostcardStatus"/>
</list>
</class>
<class name="atchik.app.postcards.kernel.model.PostcardStatus" table="PostcardStatus">
<id name="databaseId" column="id" type="long" unsaved-value="null">
<generator class="native"/>
</id>
<property name="value" column="value" type="int" not-null="true"/>
<property name="date" column="date" type="timestamp" not-null="true"/>
<property name="reason" column="reason" type="string"/>
</class>
</hibernate-mapping>