Hi,
I am having serious problem with updating my Hibernate objects on my AppFuse
project.
My mapping not sure but works for adding and I have lots of mapping between
my tables.
Here I have Customer, Dbuser, CustContact, CustInsurance, Address, Phone ...
etc.
I have searched and I have tried suggestions like (if I did properly)
.merge(),
.evict(),
cascade=none and my mapping lazy=false
I cannot solve the NonUniqueObjectException, Please help !!!
Exception:
-------------------------------------------------------------------------------
org.springframework.orm.hibernate3.HibernateSystemException: a different
object with the same identifier value was already associated with the
session: [com.vahms.model.dbobjects.Customer#3]; nested exception is
org.hibernate.NonUniqueObjectException: a different object with the same
identifier value was already associated with the session:
[com.vahms.model.dbobjects.Customer#3]
Caused by:
org.hibernate.NonUniqueObjectException: a different object with the same
identifier value was already associated with the session:
[com.vahms.model.dbobjects.Customer#3]
at
org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:556)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:259)
-------------------------------------------------------------------------------
Mapping s pn customer
---------------------
/**
* @hibernate.many-to-one column="dbuser_id" cascade="none"
outerjoin="true" not-null="true" lazy="false"
*/
/**
* @hibernate.set inverse="true" lazy="false" cascade="none"
* @hibernate.collection-key column="customer_id"
* @hibernate.collection-one-to-many
class="com.vahms.model.dbobjects.CustContact"
*/
/**
* @hibernate.set inverse="true" lazy="false" cascade="all"
* @hibernate.collection-key column="customer_id"
* @hibernate.collection-one-to-many
class="com.vahms.model.dbobjects.CustInsurance"
*/
/**
* @hibernate.set inverse="true" lazy="false" cascade="all"
* @hibernate.collection-key column="customer_id"
* @hibernate.collection-one-to-many
class="com.vahms.model.dbobjects.Customer_address"
*/
/**
* @hibernate.set inverse="true" lazy="false" cascade="all"
* @hibernate.collection-key column="customer_id"
* @hibernate.collection-one-to-many
class="com.vahms.model.dbobjects.Customer_phone"
*/
-------------------------------------------------------------------------------
I have tried these on CustomerDaoHibernate
-------------------------------------------------------------------------------
public void updateCustomer(final Customer customer) {
if (log.isDebugEnabled()) {
log.debug("customer's id: " + customer.getId());
}
/*
log.debug("customer's id test1: " + customer.getId());
getHibernateTemplate().setAlwaysUseNewSession(true);
log.debug("customer's id test2: " + customer.getId());
getHibernateTemplate().merge(customer);
*/
log.debug("customer's id test3: " + customer.getId());
HibernateTemplate hibernateTemplate = getHibernateTemplate();
Customer oldCustomer = (Customer)
hibernateTemplate.get(Customer.class, customer.getId());
//getHibernateTemplate().update(customer);
//getHibernateTemplate().merge(customer);
//getHibernateTemplate().saveOrUpdate(getHibernateTemplate().merge(customer));
log.debug("customer's id test4: " + customer.getId());
hibernateTemplate.evict(oldCustomer);
//hibernateTemplate.clear();
log.debug("customer's id test5: " +
customer.getDbuser().getFullName());
//hibernateTemplate.saveOrUpdate(customer);
hibernateTemplate.update(customer);
//hibernateTemplate.saveOrUpdate(getHibernateTemplate().merge(customer));
//getHibernateTemplate().saveOrUpdate(getHibernateTemplate().merge(customer));
// necessary to throw a DataIntegrityViolation and catch it in
CustomerManager
hibernateTemplate.flush();
//getHibernateTemplate().flush();
}
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
--
View this message in context:
http://www.nabble.com/NonUniqueObjectException-%28searched-a-lot-but-not-helping%29-tf3725087s2369.html#a10424746
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]