lundi 25 mai 2015

Injecting EntityManager in servlet, it seems not thread safe

I want to make a login app in Java EE. I thought of implementing it using a html page, a servlet and an entity class for the user, but it seems that EntityManager is not thread safe (can't be injected in the servlet and I need it to check the database) .

I read about EntityManagerFactory but I don't want to manage the life of the produced EntityManager when I can have the container do it. I think that some implementation using the DAO pattern could be made so that I can have an entity manager in the servlet, something like DAOImpl containing a manager, and have that class as a private variable in the servlet. But I couldn't find any useful tutorials online.

Could someone provide an implementation for this?

Aucun commentaire:

Enregistrer un commentaire