Sebastian wrote:
Hi,
I'm using OJB 1.01 with MySQL (com.mysql.jdbc.Driver, useAutoCommit="2"). I'm trying to persist an object that contains a RemovalAwareCollection with persistable child objects (refresh="true", auto-retrieve="true", otm-dependent="true").


I added a PBLifeCycleListener to the OTM connection. In the BeforeInsert methods I'm validating the properties of the persistable object and throw a PersistenceBrokerException when certain object's properties are out of the valid range.

For testing purpose I set a property of one of the child objects to an invalid value and tried to persist the parent object:

Entity entity = new Entity();

// ... add child elements here and set a property of one
// child element to an invalid value

Transaction tx = otm.getTransaction(conn);
try
{
  tx.begin();
  conn.makePersistent(entity);
  tx.commit();
}
catch (PersistenceBrokerException e)
{
  if (tx.isInProgress()) tx.rollback();
}

I expect that when the PersistenceBrokerException is thrown and the tx.rollback() method is executed, neither the entity object nor its child objects are persisted to the database.
But after the tx.rollback() was executed all objects (except the one with the invalid property) have been persisted to the database.


Do I misunderstand the transaction concept or is it bug?

Changing the table type in mysql from myISAM to innoDB solved it.


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to