Could someone please explain to me what the main differences are between JPA and Hibernate?
Where to use Hibernate ?
Where to use JPA?
Why not entity bean?
A little history:
Entity beans were part of EJB 1 and 2. They were hell to work with, so an alternative was due. Then Hibernate appeared. (I don't remember these times)
Hibernate evolved to be a de-facto standard in object-relational mapping. Then it was decided that a standard is needed, so the JPA specification was created, highly influenced by Hibernate.
JPA is just a specification - it defines what an ORM framework should do, and what annotations should it support. JPA is implemented by many vendors - Hibernate, EclipseLink, OpenJPA, etc.
So:
Update: About your secondary question in the comments:
Yes, you can use JPA with EJB Session beans:
@Stateless
public class YourSessionBean implements RemoteInterface {
@PersistenceContext
private EntityManager entityManager; // this is the JPA EntityManager
}
And you have the entity manager injected by the container and ready to operate JPA entities. Of course you'd need to make configurations for that, but that's out of the scope of this question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With