In Thread-safety when injecting EntityManager post, I wrote about the danger of using field/setter injection to get EntityManager in servlets and compares container-managed EntityManager vs application-managed EntityManager.
What if I need a container-managed EntityManager in my servlet class?
There are 2 ways to do that:
1. type-level injection + JNDI lookup
2. web.xml + JNDI lookup
The persistence-context-ref is declared in web.xml:
What if I need a container-managed EntityManager in my servlet class?
There are 2 ways to do that:
1. type-level injection + JNDI lookup
2. web.xml + JNDI lookup
The persistence-context-ref is declared in web.xml:
No comments :
Post a Comment