Hi,
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")
@Interceptors(Interceptor1.class)
public class Facade1Bean implements Facade1 {
@PersistenceContext(unitName = "unit1")
EntityManager em;
public void createDept ( Department aDepartment )
throws AppException {
try {
Employee e1 = new Employee();
e1.setXXX()
aDepartment.addEmployee( e1 );
em.persist( aDepartment );
em.flush();
Department newDept = em.find( Department.class,
aDepartment.getDeptId()
);
if ( newDept == null ) {
throw new AppException(
.... );
}
em.refresh( newDept );
//add other employees
Employee e2 = new Employee();
e2.setXXX()
newDept.addEmployee( e2 );
Employee e3 = new Employee();
e3.setXXX()
newDept.addEmployee( e3 );
em.persist( newDept );
em.flush();
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
below:
<persistence-unit name=" unit1" transaction-type="JTA">
<provider>
org.apache.openjpa.persistence.PersistenceProviderImpl
</provider>
<jta-data-source>myDataSource</jta-data-source>
….
--
View this message in context:
http://n2.nabble.com/Problem-of-partial-commit-in-OpenJPA-tp4891679p4891679.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.