openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <kwsut...@gmail.com>
Subject Re: Problem of partial commit in OpenJPA
Date Mon, 12 Apr 2010 19:18:05 GMT
I'm not a WebLogic expert, but it looks like the AppException (with rollback
action) is not being processed correctly by the WebLogic container.  It
looks like your exception is declared properly to have the "rollback"
action.  And, if your app is throwing this exception right after the find on
the Department.class, then the tran should be rolled back and nothing should
be committed to the database.  From the information provided, it looks like
OpenJPA is processing as expected and you need to follow up with the
WebLogic App Server folks.

Kevin

On Mon, Apr 12, 2010 at 12:56 PM, Sudhir K Sethi <ksudhir.sethi@gmail.com>wrote:

>
> 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.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message