Wednesday, June 9, 2010

Entity Manager Vs. Entity Manager Factory

For those who are confused between entityManager and entitymanager factory, here is a short and simple explanation. An entity manager is an instance inside a persistence context that manages entities. An entity manager factory is an interface that is used to obtain the application managed entity manager. An entity manager factory can create entity manager(s).

There are two types of entity managers : container managed entity managers and application managed entity managers. If you use container managed entity managers, you don't have to worry about a lot of things. The containers that you use(for example I use Seam) will take care of everything. The application managed entity manager is the other way round. There'll be certain situations in which you might want to control you entity manager instead of having a container take care of it.

No comments:

Post a Comment