This content has been marked as final. 
    
Show                 7 replies
    
- 
        1. Re: Persistence context invocation upon application startupmcanaleta Jan 4, 2008 6:00 AM (in response to fady.matar)Try injecting the entityManager: @In("entityManager") private EntityManager em;
 It works for me in an application scoped component for initializing purposes, like you need. I'd like to know the difference of injecting it or using the @PersistentContext annotation...
 Hope it helps!
- 
        2. Re: Persistence context invocation upon application startupfady.matar Jan 4, 2008 6:12 AM (in response to fady.matar)afaik @PersistentContext can be used only with session beans and message driven beans 
- 
        3. Re: Persistence context invocation upon application startuppmuir Jan 4, 2008 6:35 AM (in response to fady.matar)You can use @PersistenceContext (if you make it a @Stateful bean) or @In EntityManager entityManager; if you have an SMPC configured in components.xml 
- 
        4. Re: Persistence context invocation upon application startupfady.matar Jan 4, 2008 6:37 AM (in response to fady.matar)That works, thanks 
- 
        5. Re: Persistence context invocation upon application startupfady.matar Jan 4, 2008 6:50 AM (in response to fady.matar)One limitation in here, I can query the properly however I cannot save entities the em.persist(Object obj) 
 seems to do nothing, even at the sql logging level I can see all the selects but not inserts.
- 
        6. Re: Persistence context invocation upon application startupfady.matar Jan 4, 2008 7:39 AM (in response to fady.matar)I had to convert the startup POJO into a stateful bean, use the persistence context and now it works like charm. 
 Thanks again Pete ;-)
- 
        7. Re: Persistence context invocation upon application startupmcanaleta Jan 4, 2008 8:11 AM (in response to fady.matar)I don't need to convert to a Stateful Bean, my POJO can persist entities, i think the difference is that my startup method is annotated @Transactional. 
 
     
    