[jboss-dev-forums] [JBoss AS7 Development] - jboss7 quickstarts entitymanager injection question

robert walker do-not-reply at jboss.com
Mon Nov 7 16:27:11 EST 2011


robert walker [http://community.jboss.org/people/robertwalker] created the discussion

"jboss7 quickstarts entitymanager injection question"

To view the discussion, visit: http://community.jboss.org/message/635427#635427

--------------------------------------------------------------
Hi all, I am looking at the examples in jboss7 quickstarts , login and kithensink (ones that hit a DB)
and wondering how jb7 knows which persistence unit to inject.

for example

if standalone.xml defines a few datasources  (like the default)

.....


 and say another named  "MyDataDSource"


....


how does jboss know which one to inject when executing code like this from login quickstart's   ManagedBeanUserManager.java file

@Inject
private EntityManager userDatabase;


No designation which PU to to inject,  I was thinking there would have to be code along the idea of the snippet below

@PersistenceContext(unitName = "MyDataDSource")
EntityManager em;


I did read the "Chapter 5. CDI + JPA + EJB + JTA + JSF: Login quickstart" but was eagerly wanting to know how jboss knows which 
one to inject but didn't see it, which means it's so obvious that it does not need to be stated. So I realize i should know it this
but I don''t. :-(

I see the the pattern suggested by CDI is resource producers, but 
Resources.java has 

   // Expose an entity manager using the resource producer pattern

   @SuppressWarnings("unused")

   @PersistenceContext

   @Produces

   private EntityManager em;

with no designation either

can someone point me to a reesource to explain this a bit more

thanks
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/635427#635427]

Start a new discussion in JBoss AS7 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20111107/39fabed4/attachment.html 


More information about the jboss-dev-forums mailing list