You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Stephen Ting <st...@shinyang.com.my> on 2003/07/15 11:50:09 UTC

Transaction in PB api

I have the following problem in PB transaction. I have an object with
1:M relationship. In testing, I found that when there are error in
persisting the line item of the header object. The header still
persisted to database whereas the line item didn't. 

I am expecting whenver there any errors, it will roll back and no saving
being done.. Can anyone show me how to do this in PB API? What actually
PB transaction can do and don't?

I used PB api in session bean. 


try{ 
	broker = getBroker(new PBKey(site.getDbConnectionAlias()));
	broker.beginTransaction();
	broker.store(document); 
	broker.commitTransaction(); 
}catch(PersistenceBrokerException ex){ 
	broker.abortTransaction();
	broker.close();
	throw new ServiceException(ex.getMessage());
}finally{
	if(broker != null){
		broker.close(); 
	}
}

Regards,

Stephen Ting


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org