Upon trying to save cascaded entries, I'm getting the same exception that a lot of people have complained about:
Quote:
17:22:09,329 ERROR SessionImpl:2343 - Could not synchronize database state with session
net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
Except I actually read through the faqs and searched the forums. I've added unsaved-value="null" to all my classes, but I still get the same problem. The only way I can avoid this problem is by ensuring that the set containing the cascaded data is empty.
I would like to stress that I am not updating nor deleting. The following java code is all I am doing(Each Order object contains a set of OrderItem objects):
Code:
Order o = createOrder();
Session session = null;
Transaction tx = null;
try
{
session = sf.openSession();
}
catch( PersistenceException pe )
{
throw new RuntimeException( "* ERROR openening session." );
}
try
{
tx = session.beginTransaction();
session.save( o );
tx.commit();
}
catch( PersistenceException pe )
// and so on.......
If I just try saving the OrderItems that are within o, I get no exception.
Any ideas?
Thank you for your time.