openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sudhir K Sethi <>
Subject Problem of partial commit in OpenJPA
Date Mon, 12 Apr 2010 17:56:10 GMT


I am getting cases of partial commit in OpenJPA (1.1.x and 1.2.x). I am
using Weblogic server 10.3 and Oracle 10g. Here is the scenario to get this:

I have 2 classes whose relation is aggregation/composition. Department has
‘n’ number of Employees. Inside my façade I have used code as below:

//import statements

@Stateless(name = "Facade10", mappedName = "FacadeMapped10")
public class Facade1Bean implements Facade1 {
	@PersistenceContext(unitName = "unit1")
	EntityManager em;

	public void createDept ( Department aDepartment )
			throws AppException {
		try {

			Employee e1 = new Employee();
			aDepartment.addEmployee( e1 );

			em.persist( aDepartment );

			Department newDept = em.find( Department.class, aDepartment.getDeptId()
			if ( newDept == null ) {
				throw new AppException(
						.... );
			em.refresh( newDept );

			//add other employees
			Employee e2 = new Employee();
			newDept.addEmployee( e2 );

			Employee e3 = new Employee();
			newDept.addEmployee( e3 );

			em.persist( newDept );
			em.refresh( newDept );

		finally {
			//clean up code
	//other code in class


AppException is codes as:

@ApplicationException(rollback = true)
public class AppException extends Exception {
	//costructor and other methods


When exception does not have I get all objects in tree saved in DB as
dept1{e1, e2, e3}.

When exception occurs I get partial commit of data in DB in which case the
state of objects is: dept1{e1}. But I want the entire tree to be either
saved or rolled back. Please let me know where I am going wrong? Is there
any special elements needed in persistence.xml so that the transaction in
facade bounds to container?

 I am using container managed transaction and my persistence.xml is as

<persistence-unit name=" unit1" transaction-type="JTA">

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message