tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pascal Knüppel (JIRA) <j...@apache.org>
Subject [jira] [Comment Edited] (OPENEJB-2120) JPA 2.1 Support
Date Thu, 29 Oct 2015 09:33:27 GMT

    [ https://issues.apache.org/jira/browse/OPENEJB-2120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14980112#comment-14980112
] 

Pascal Knüppel edited comment on OPENEJB-2120 at 10/29/15 9:33 AM:
-------------------------------------------------------------------

Hi I've got another question on this issue.

The tip you gave me with unwrap works perfectly fine, but if I inject an EJB that is injecting
an EntityManager and another class that also is injecting an EntityManager of the same persistence-unit,
how could I make sure that the unwrap is reached through the injections?

to make it clearer:
{code:title=Bar.java|borderStyle=solid}
@LocalClient
public class MyJUnitTest {

      ... // some OpenEjb configurations

    @PersistenceContext(unitName = DBDefinitions.ORACLE_PERSISTENCE_UNIT)
    private EntityManager oracleEntityManager;

    @Inject
    private Service service;

   @Test
   public void myTest() {
        oracleEntityManager = oracleEntityManager.unwrap(JpaEntityManager.class);
        service.executeTasks();
        // some assertions
   }
}

@Stateless
public class Service {
    @PersistenceContext(unitName = DBDefinitions.ORACLE_PERSISTENCE_UNIT)
    private EntityManager oracleEntityManager;

    @Inject
    RequestHandler myRequestHandler
    ...
}

@Dependent
public class RequestHandler {
    @PersistenceContext(unitName = DBDefinitions.ORACLE_PERSISTENCE_UNIT)
    private EntityManager oracleEntityManager;
    ...
} 
{code}

in this example it is obvious that the overriden EntityManager is not reached through to class
Service and RequestHandler. I get the openejb JtaEntityManager in these classes. Is there
a way to guarantee that the injected classes will always have the JpaEntityManager instead
of JtaEntityManager without interfering manually at any spot where the EntityManager is injected?


was (Author: captgoldfish):
Hi I've got another question on this issue.

The tip you gave me with unwrap works perfectly fine, but if I inject an EJB that is injecting
an EntityManager and another class that also is injecting an EntityManager of the same persistence-unit,
how could I make sure that the unwrap is reached through the injections?

to make it clearer:

@LocalClient
public class MyJUnitTest {

      ... // some OpenEjb configurations

    @PersistenceContext(unitName = DBDefinitions.ORACLE_PERSISTENCE_UNIT)
    private EntityManager oracleEntityManager;

    @Inject
    private Service service;

   @Test
   public void myTest() {
        oracleEntityManager = oracleEntityManager.unwrap(JpaEntityManager.class);
        service.executeTasks();
        // some assertions
   }
}

@Stateless
public class Service {
    @PersistenceContext(unitName = DBDefinitions.ORACLE_PERSISTENCE_UNIT)
    private EntityManager oracleEntityManager;

    @Inject
    RequestHandler myRequestHandler
    ...
}

@Dependent
public class RequestHandler {
    @PersistenceContext(unitName = DBDefinitions.ORACLE_PERSISTENCE_UNIT)
    private EntityManager oracleEntityManager;
    ...
} 


in this example it is obvious that the overriden EntityManager is not reached through to class
Service and RequestHandler. I get the openejb JtaEntityManager in these classes. Is there
a way to guarantee that the injected classes will always have the JpaEntityManager instead
of JtaEntityManager without interfering manually at any spot where the EntityManager is injected?

> JPA 2.1 Support
> ---------------
>
>                 Key: OPENEJB-2120
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-2120
>             Project: OpenEJB
>          Issue Type: Wish
>          Components: general
>            Reporter: Pascal Knüppel
>            Assignee: Romain Manni-Bucau
>              Labels: jpa21
>
> It would be really great if support for JPA 2.1 was provided. Is there any chance that
support for this api level will come soon?
> In order to keep my Unit-Tests alive I need to downgrade all the requests to the database
to jpa 2.0 which makes working on my project very difficult...



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

Mime
View raw message