I am using the below hbm file.
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="com.kroger.accounting.rem.bo.RentChange"
table="RNT_CHG_HST"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="RNT_CHG_HST_ID"
type="long"
unsaved-value="0"
>
<generator class="native">
</generator>
</id>
<property
name="arrears"
type="java.lang.Boolean"
update="true"
insert="true"
column="ARR_FL"
/>
<property
name="effectiveDate"
type="java.sql.Date"
update="true"
insert="true"
column="RNT_CHG_EFF_DT"
/>
<property
name="oneTimePayDate"
type="java.sql.Date"
update="true"
insert="true"
column="OTM_PMT_DT"
/>
<property
name="endDate"
type="java.sql.Date"
update="true"
insert="true"
column="RNT_CHG_END_DT"
/>
<many-to-one
name="lease"
class="com.kroger.accounting.rem.bo.Lease"
cascade="none"
outer-join="auto"
update="true"
insert="true"
>
<column
name="LSE_ID"
/>
</many-to-one>
<property
name="monthlyRent"
type="java.math.BigDecimal"
update="true"
insert="true"
column="RNT_CHG_MON_RNT_AM"
/>
<many-to-one
name="option"
class="com.kroger.accounting.rem.bo.LeaseOption"
cascade="none"
outer-join="auto"
update="true"
insert="true"
>
<column
name="LSE_OPT_ID"
/>
</many-to-one>
<property
name="paymentDueDay"
type="java.lang.Integer"
update="true"
insert="true"
column="PMT_DAY_NO"
/>
<property
name="paymentDueMonth"
type="java.lang.Integer"
update="true"
insert="true"
column="PMT_MON_NO"
/>
<many-to-one
name="rentPaymentFrequency"
class="com.kroger.accounting.rem.bo.RentPaymentFrequency"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="RNT_PMT_FRQ_ID"
/>
<property
name="rentPaymentFrequencyId"
type="java.lang.Long"
update="true"
insert="true"
column="RNT_PMT_FRQ_ID"
/>
<many-to-one
name="rentType"
class="com.kroger.accounting.rem.bo.RentType"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="RNT_TYP_ID"
/>
<property
name="rentTypeId"
type="java.lang.Long"
update="true"
insert="true"
column="RNT_TYP_ID"
/>
<bag
name="vendors"
lazy="false"
inverse="false"
cascade="all-delete-orphan"
>
<key>
<column name="RNT_CHG_HST_ID"/>
</key>
<one-to-many
class="com.kroger.accounting.rem.bo.LeaseVendor"
/>
</bag>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-RentChange.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
and spring configuration file is
<bean id="leaseService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref local="remTransactionManager"/></property>
<property name="target"><ref local="leaseTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="retrieve*">PROPAGATION_SUPPORTS</prop>
<prop key="add">PROPAGATION_REQUIRED,-DBException,-IdExistsException,-ServiceException,-DataException</prop>
<prop key="update*">PROPAGATION_REQUIRED,-DBException,-ServiceException,-DataException</prop>
<prop key="delete*">PROPAGATION_REQUIRED,-DBException,-ServiceException,-DataException</prop>
</props>
</property>
</bean>
when i am updating i am not getting any error.
When i am adding, getting the following error.
org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: com.kroger.accounting.rem.bo.LeaseOption
If i changed cascade "none" to "all"
it showing the following exception
org.springframework.orm.hibernate.HibernateSystemException: a different object with the same identifier value was already associated with the session: 18713, of class: com.kroger.accounting.rem.bo.Lease; nested exception is net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 18713, of class: com.kroger.accounting.rem.bo.Lease
any body has any idea how to solve..
please reply me soon.
|