These are the two code snippets given in
EJB 3 in Action on page 448 and page 449:
//--- Do NOT do this!!! This is not recommended!!!
public class ActionBazaarBidControllerServlet extends HttpServlet{
@PersistenceContext(unitName="actionBazaar")
private EntityManager entityManager;
}
and
@PersistenceContext(name="actionBazaar/EntityManager", unitName="actionBazaar")
public class ActionBazaarBidControllerServlet extends HttpServlet{
private EntityManager entityManager;
}
I am not able to understand how these two are different. I know that the
Servlet is a multi threaded environment and EntityManager is not
thread safe, but how is the 2nd code snippet any different from the first one?