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/02/08 17:05:39 UTC

[jira] [Commented] (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:comment-tabpanel&focusedCommentId=15137139#comment-15137139 ] 

Christian Schneider commented on ARIES-1494:
--------------------------------------------

On the first call to delete the entitymanager is created and auto joins the transaction. Then the trasnactions is committed.
On the second call the entitymanager is already there and does not join the transaction.

So the fix is to make sure we always join running transactions.

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