[weld-dev] rationale for JTA/JPA questions - trying to add JPA support to archetypes

Gavin King gavin.king at gmail.com
Sat Nov 28 12:40:01 EST 2009


No, in EE5 you used @PersistenceContext, which is nontypesafe and  
doesn't support stuff like alternatives. In EE6 you should use CDI to  
@Inject your EntityManager just like any other bean.

Sent from my iPhone

On Nov 28, 2009, at 12:17 PM, Steven Boscarine <steven.boscarine at childrens.harvard.edu 
 > wrote:

> So normally on JEE6, you'd user @PersistenceContext, right?  That's  
> certainly the case if you're using JEE5 or Spring right now.   
> Therefore if switching containers or running in SE, they'd have to  
> change all @PersitenceContext annotations to @Inject, correct?
>
> If you're asking me, representing myself, I don't care much.  I  
> don't get too worked up if I have to jump through a hoop or two to  
> get the plumbing in my app configured.  I just want effective  
> documentation to know how to get my job done.  At the end of the  
> day, my users care about my application's features, reliability, and  
> response time.  I know how to work my IDE's find and replace if I  
> find myself in that situation.  As an experienced user, I am used to  
> working around "paper cuts."
>
> Trying to put myself in the user's place, it'd be nice if their Java  
> code could be switched between containers.  I think the platform  
> looks better if there is minimal branching, especially on the Java  
> side.  If we're reaching out to SE and Servlet users, it'd be ideal  
> if they could use the same annotations.  However, I don't think this  
> one tiny detail alone will be a big enough reason to lose a user.   
> As long as things are well documented, experienced professionals  
> will just follow the directions to get the plumbing out of the way  
> and move on to doing the interesting part of their application.
> IMO the biggest concern will be when writing examples.  I think the  
> less motivated and experienced users will get frustrated when they  
> paste a sample from an example app, blog post, or documentation and  
> get a null pointer exception.  Will JEE6 users get a NPE if they use  
> @Inject EntityManager em; without special configuration?
>
> Why is it so much more difficult to inject via @PersistenceContext  
> than @Inject?
> Gavin King wrote:
>> That's more or less an easy problem to solve. But why do you want to
>> inject it using @PersistenceContext instead of @Inject??
>>
>>


More information about the weld-dev mailing list