Hi,
As we have performance problems we want to avoid any unnecessary operations on database. That's why we want to avoid an update on just inserted object.
We have an object Fee that is assosciated with Contract object. One Contract can have a set of Fees.
We create a new Fee object (and assosciate it with Contract at once) .Just after that we add this Fee to a set of fees that has a Contract.
In hibernate log we can see that:
- at first a Fee is created
- later a Fee is updated (although the object is exactly the same as during insert).
Is there any method to avoid this update? I understand this update must be somehow related to setting feeSet to a Contract.
CODE:
Fee newCopy = new Fee(oldFee, newContract);
feeSet.add(newCopy);
FeeDao.getInstance().save(newCopy);
newContract.setFeeSet(feeSet);
SessionTxManager.commit();
HIBERNATE LOG:
Hibernate: insert into FEE (CONTRACT_ID, E_CONTRACT_ACCOUNT_NO, .. FEE_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: update FEE set CONTRACT_ID=? where FEE_ID=?
Hibernate version:
2.1.6
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
Oracle 9.2.05
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
|