Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JNDI Lookup code for EntityMananger inside SessionBean  RSS feed

Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I am using JNDI look up inside my stateless session Bean for Thread Safety issues .

That is

@PersistenceContext(Unitname="someunit" name= "somename")

Context ctx = new InitialContext();

EntityManager em = (EntityManager)ctx.lookup("somename")

Now i am having 4 methods for (CRUD) inside my sessionBean

Do i need to use this lookup code inside my every method that is in all my 4 methods

Please tell me this if i am having four methods inside my Session Bean do i need to do lookup inside each of my method.
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!