What does EntityManager::getDelegate return?
ejb-3.0, java, jpa
Solution
JPA is just a specification for ORM; there are some implementations for this specification/API the most known being Hibernate, EclipseLink, OpenJPA.
This means that the `EntityManager` is just an adapter to a class from the implementation library. In your case it is `org.hibernate.internal.SessionImpl` since you use Hibernate as a JPA implementation - this is the class that manages the code you give to the `EntityManager`.
Problem
I am using JBoss 7 with the default Hibernate JPA engine in an EJB3 / JSF project. The javadoc on EntityManager::getDelegate reads: "Return the underlying provider object for the EntityManager, if available.". Out of curiosity I tried the following code: ``` @Stateless public class AFacade { @PersistenceContext(unitName="foo") EntityManager em; public List<A> findAll() { l.info("underlying entity manager is: "+em.getDelegate().getClass().getSimpleName()); ... } ``` The output however indicates the classname as: org.hibernate.internal.SessionImpl which, according to hibernate documentation is a Session implementation. What am I missing here ?