You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by "Christian Schneider (JIRA)" <ji...@apache.org> on 2016/10/26 14:39:58 UTC

[jira] [Resolved] (ARIES-1494) Exception when calling a transactional method twice from a non transaction method

     [ https://issues.apache.org/jira/browse/ARIES-1494?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christian Schneider resolved ARIES-1494.
----------------------------------------
    Resolution: Won't Fix

I talked to Tim about this issue. The problem is that this kind of extended persistence context lifecycle is not well defined. So we can not rely on this to work.

The result is that if you need a transaction you have to start the transaction when you first access the entity manager. 

> Exception when calling a transactional method twice from a non transaction method
> ---------------------------------------------------------------------------------
>
>                 Key: ARIES-1494
>                 URL: https://issues.apache.org/jira/browse/ARIES-1494
>             Project: Aries
>          Issue Type: Bug
>          Components: JPA
>    Affects Versions: jpa-2.3.0
>            Reporter: Christian Schneider
>            Assignee: Christian Schneider
>             Fix For: jpa-2.5.0
>
>
> This issue was reported by Nicolas Dutertry on the karaf user list:
> http://karaf.922171.n3.nabble.com/JPA-and-transaction-issue-in-Karaf-4-0-4-td4045208.html
> He also provided a repository with a demo (which I forked):
> https://github.com/cschneider/test-jpa
> In short TestServiceImpl has a non Transactional method:
>     public void delete(String... names) {
>         for (String name : names) {
>             System.out.println("Deleting " + name);
>             deleteManager.delete(name);
>         }
>     }
> It calls DeleteManager
>     @Transactional
>     public void delete(String lastName) {
>         Query query = entityManager.createQuery(
>             "delete from Person where lastName = :lastName");
>         
>         query.setParameter("lastName", lastName);
>         query.executeUpdate();
>     }
> If the method TestServiceImpl.delete is called with one name then it works.
> If it is called with two names it fails.
> It is not even necessary to first create the person records to show the error.
> A workaround is to make the method TestServiceImpl.delete also transactional. Then it works.
> I will create a test case in the jpa code and fix the issue.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)