Chapter 1. Introduction
1.1. About Hibernate Core
Hibernate Core is an object-relational mapping framework for the Java language. It provides a framework for mapping an object-oriented domain model to a relational database, allowing applications to avoid direct interaction with the database. Hibernate solves object-relational impedance mismatch problems by replacing direct, persistent database accesses with high-level object handling functions.
1.2. Hibernate EntityManager
Hibernate EntityManager implements programming interfaces and lifecycle rules as defined by the Jakarta Persistence 2.2 specification. Together with Hibernate Annotations, this wrapper implements a standalone Jakarta Persistence solution on top of the mature Hibernate Core. You can use a combination of all three together, annotations without Jakarta Persistence programming interfaces and lifecycle, or even pure native Hibernate Core, depending on the business and technical needs of your project. You can at all times fall back to Hibernate native APIs, or if required, even to native JDBC and SQL. It provides JBoss EAP with a complete Jakarta Persistence solution.
The 7.3 release of JBoss EAP is compliant with the Jakarta Persistence 2.2 specification defined in Jakarta EE 8.
Hibernate also provides additional features to the specification. To get started with Jakarta Persistence and JBoss EAP, see the
kitchensink quickstarts that ship with JBoss EAP.
Jakarta Persistence is available in containers like Jakarta Enterprise Beans 3 or the more modern Jakarta Contexts and Dependency Injection, as well as in standalone Java SE applications that execute outside of a particular container. The following programming interfaces and artifacts are available in both environments.
If you plan to use a security manager with Hibernate, be aware that Hibernate supports it only when
EntityManagerFactory is bootstrapped by the JBoss EAP server. It is not supported when the
SessionFactory is bootstrapped by the application.
- An entity manager factory provides entity manager instances, all instances are configured to connect to the same database, to use the same default settings as defined by the particular implementation, etc. You can prepare several entity manager factories to access several data stores. This interface is similar to the SessionFactory in native Hibernate.
- The EntityManager API is used to access a database in a particular unit of work. It is used to create and remove persistent entity instances, to find entities by their primary key identity, and to query over all entities. This interface is similar to the Session in Hibernate.
- Persistence context
- A persistence context is a set of entity instances in which for any persistent entity identity there is a unique entity instance. Within the persistence context, the entity instances and their lifecycle is managed by a particular entity manager. The scope of this context can either be the transaction, or an extended unit of work.
- Persistence unit
- The set of entity types that can be managed by a given entity manager is defined by a persistence unit. A persistence unit defines the set of all classes that are related or grouped by the application, and which must be collocated in their mapping to a single data store.
- Container-managed entity manager
- An entity manager whose lifecycle is managed by the container.
- Application-managed entity manager
- An entity manager whose lifecycle is managed by the application.
- Jakarta Transactions entity manager
- Entity manager involved in a Jakarta Transactions transaction.
- Resource-local entity manager
- Entity manager using a resource transaction (not a Jakarta Transactions transaction).
- For information about how to download and run the quickstarts, see Using the Quickstart Examples in the JBoss EAP Getting Started Guide.
- For more information about security managers, see Java Security Manager in the JBoss EAP How to Configure Server Security .