You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Prabhat (Created) (JIRA)" <ji...@apache.org> on 2012/03/16 16:09:38 UTC

[jira] [Created] (OPENJPA-2155) Transaction Management in multiple Entities in one transaction

Transaction Management in multiple Entities in one transaction
--------------------------------------------------------------

                 Key: OPENJPA-2155
                 URL: https://issues.apache.org/jira/browse/OPENJPA-2155
             Project: OpenJPA
          Issue Type: Question
          Components: jpa
    Affects Versions: 2.1.1
         Environment: WebSphere Application Server 6.1.37 on Windows and AIX
            Reporter: Prabhat


I am a new user on OpenJPA,
I have a scenario where I need to perform update/insert in multiple entities on one transaction. How to achieve this?

example of EntityManager update method (auto generated by Rational Software Architect8.0.3). [ The same way, I have two more entities. ]
==================
	@Action(Action.ACTION_TYPE.UPDATE)
	public String updateKna1(Kna1 kna1) throws Exception {
		EntityManager em = getEntityManager();
		try {
			em.getTransaction().begin();
			kna1 = em.merge(kna1);
			em.getTransaction().commit();
		} catch (Exception ex) {
			try {
				if (em.getTransaction().isActive()) {
					em.getTransaction().rollback();
				}
			} catch (Exception e) {
				ex.printStackTrace();
				throw e;
			}
			throw ex;
		} finally {
			////em.close();
		}
		return "";
	}

==========================
If I keep commit/rollback in each entity then I can not rollback from all previous entities (if last entity insert or update fails).

Can you help me on this?

Thanks in Advance.



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Closed] (OPENJPA-2155) Transaction Management in multiple Entities in one transaction

Posted by "Rick Curtis (Closed) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2155?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Curtis closed OPENJPA-2155.
--------------------------------

    Resolution: Not A Problem

Please utilize the OpenJPA (users) mailing list[1] for questions. JIRA should be used for bugs and/or features.

Thanks,
Rick

[1] http://openjpa.apache.org/mailing-lists.html
                
> Transaction Management in multiple Entities in one transaction
> --------------------------------------------------------------
>
>                 Key: OPENJPA-2155
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2155
>             Project: OpenJPA
>          Issue Type: Question
>          Components: jpa
>    Affects Versions: 2.1.1
>         Environment: WebSphere Application Server 6.1.37 on Windows and AIX
>            Reporter: Prabhat
>              Labels: Transaction
>
> I am a new user on OpenJPA,
> I have a scenario where I need to perform update/insert in multiple entities on one transaction. How to achieve this?
> example of EntityManager update method (auto generated by Rational Software Architect8.0.3). [ The same way, I have two more entities. ]
> ==================
> 	@Action(Action.ACTION_TYPE.UPDATE)
> 	public String updateKna1(Kna1 kna1) throws Exception {
> 		EntityManager em = getEntityManager();
> 		try {
> 			em.getTransaction().begin();
> 			kna1 = em.merge(kna1);
> 			em.getTransaction().commit();
> 		} catch (Exception ex) {
> 			try {
> 				if (em.getTransaction().isActive()) {
> 					em.getTransaction().rollback();
> 				}
> 			} catch (Exception e) {
> 				ex.printStackTrace();
> 				throw e;
> 			}
> 			throw ex;
> 		} finally {
> 			////em.close();
> 		}
> 		return "";
> 	}
> ==========================
> If I keep commit/rollback in each entity then I can not rollback from all previous entities (if last entity insert or update fails).
> Can you help me on this?
> Thanks in Advance.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira