[cdi-dev] Needed failing for JPA / EJB

Pete Muir pmuir at redhat.com
Wed Apr 18 02:15:25 EDT 2012


Yes, I think it's reasonable to say that you can't in Java EE 6 inject an XPC into a CDI bean. We should look at changing this, though, especially as we add transactions to managed beans, it may make sense to offer an extended PC here in the future.

Can you clarify what you mean by an unmanaged EM? As @PersistenceContext always gives you a managed EM, and I think it be very odd to change this. Also, as managed beans will have transactions, I really don't think we want to force people to use unmanaged EMs.

On 18 Apr 2012, at 05:41, Mark Struberg wrote:

> Yup this caused a lot confusion because some containers silently inject an Unmanaged EntityManager if it's not an EJB, others inject a Managed EntityManager _despite_ it's not an EJB, ...
> 
> I'd say we should either define that it should inject an unmanaged EM or define to throw an Exception in that case.
> 
> 
> LieGrue,
> strub
> 
> 
> 
> 
>> ________________________________
>> From: Dan Allen <dan.j.allen at gmail.com>
>> To: Jason Porter <lightguard.jp at gmail.com> 
>> Cc: cdi-dev at lists.jboss.org 
>> Sent: Wednesday, April 18, 2012 12:49 AM
>> Subject: Re: [cdi-dev] Needed failing for JPA / EJB
>> 
>> 
>> Note that the point here is the use of the extended persistence context injection on a regular managed bean, not an EJB.
>> 
>> 
>> -Dan
>> 
>> 
>> p.s. This lends itself well to an Arquillian test for demonstrating the current and desired exceptions.
>> 
>> 
>> On Tue, Apr 17, 2012 at 18:37, Jason Porter <lightguard.jp at gmail.com> wrote:
>> 
>> I don't know where this should fail, but it needs to fail somewhere, and if CDI isn't it, I trust there are people on this list the other EGs will listen to because too many of them ignore the users list, because you know, they're the "experts".
>>> 
>>> 
>>> public class EmProducer() {
>>>     @PersistenceContext(type = PersistenceContextType.EXTENDED)
>>>     EntityManager em;
>>> 
>>> 
>>>     @Produces @RequestScoped
>>>     public EntityManager getEntityManager() {
>>>         return em;
>>>     }
>>> }
>>> 
>>> 
>>> That should be a deployment exception stating it isn't valid (the @PersistenceContext injection).
>>> -- 
>>> Jason Porter
>>> http://lightguard-jp.blogspot.com
>>> http://twitter.com/lightguardjp
>>> 
>>> Software Engineer
>>> Open Source Advocate
>>> Author of Seam Catch - Next Generation Java Exception Handling
>>> 
>>> PGP key id: 926CCFF5
>>> PGP key available at: keyserver.net, pgp.mit.edu
>>> 
>>> _______________________________________________
>>> cdi-dev mailing list
>>> cdi-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>>> 
>>> 
>> 
>> 
>> 
>> -- 
>> 
>> Dan AllenPrincipal Software Engineer, Red Hat | Author of Seam in Action
>> Registered Linux User #231597
>> 
>> 
>> http://google.com/profiles/dan.j.allen
>> http://mojavelinux.com
>> http://mojavelinux.com/seaminaction
>> 
>> 
>> _______________________________________________
>> cdi-dev mailing list
>> cdi-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>> 
>> 
>> 
> 
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev




More information about the cdi-dev mailing list