With version 6.0, Hibernate ORM has moved to expect Java 11 as its baseline version. It has also moved from Java Persistence as defined by the Java EE specs to Jakarta Persistence as defined by the Jakarta EE spec. We shall be using the jakarta.persistence
. packages instead of javax.persistence.
packages, starting from Hibernate version 6.0.
Note that Jakarta provides a transformer tool that can help in transforming a project from Java Persistence to Jakarta Persistence.
The following articles have been published to help you start with some very common tasks involving persistence with Hibernate and JPA.
1. Getting Started
- Hibernate Hello World Example
- Bootstrapping SessionFactory in Hibernate
- Bootstrapping EntityManager in Hibernate
2. Basics
- Hibernate Entity Lifecycle
- Hibernate Entity Lifecycle Events and Callbacks
- EntityManager getReference() vs find() APIs
- Checking Hibernate Entity Equality between Sessions
- Hibernate save(), update() and saveOrUpdate()
- Hibernate get() vs load() Methods
- Hibernate Merging and Refreshing Entities
- Inserting Objects with Hibernate
- Deleting Entities with Hibernate
- Hibernate Annotations Vs Mappings
3. Annotations
- Hibernate/JPA Persistence Annotations
- Hibernate Natural Ids with @NaturalId
- Hibernate @Immutable Entities
- Hibernate @NamedStoredProcedureQuery
4. Configurations
- Configure In-memory DB to Unit Test Hibernate
- Lazy Loading in Hibernate
- Hibernate JPA Cascade Types
- Initializing a Proxy Entity with Hibernate
- Mocking an In-memory JNDI DataSource
- Configuring Hibernate 5 with Spring Boot 2
5. Mapping
- Defining Hibernate Association Mappings
- Hibernate One to One Mapping
- Hibernate One to Many Mapping
- Hibernate Many to Many Mapping
- Hibernate Mapping Date, Time and Timestamp
6. SQL, HQL
- Hibernate Named Query Examples
- Handling BLOB and CLOB with Hibernate
- Guide to Hibernate Query Language
- Guide to Hibernate Criteria Queries
- Stored Procedures with Hibernate
7. Logging, Caching, Pooling, Validation
- Guide to Hibernate First Level Cache
- Guide to Hibernate Second Level Cache
- Hibernate 4 EhCache 2 Configuration
- Configuring Ehcache 3 with Hibernate 6
- Hibernate Connection Pooling with c3p0
- Java Bean Validation using Hibernate Validator
- Bootstrapping ValidationFactory with Hibernate Validator CDI
8. Errors
- Hibernate Error: Unable to locate persister
- [Solved] Initial SessionFactory creation failed.org.hibernate.HibernateException: Errors in named queries
- [SOLVED] org.hibernate.ObjectNotFoundException: No row with the given identifier exists
- [SOLVED] Bean property ‘configurationClass’ is not writable or has an invalid setter method
- [SOLVED] java.lang.NoClassDefFoundError: Lorg/hibernate/cache/CacheProvider
- [SOLVED] java.lang.NoClassDefFoundError: org/hibernate/engine/SessionFactoryImplementor
- [Workaround] NotYetImplementedException: Pure native scalar queries are not yet supported
- [Solved] org.hibernate.exception.GenericJDBCException: could not prepare statement
- [Solved] org.hibernate.QueryException: Cannot mix named and positional parameters
- [Solved] HsqlException: data exception: invalid character value for cast
- [Solved] – UnexpectedTypeException- No validator could be found for constraint
9. Advance Topics
- Hibernate count, min, max, sum, avg
- Guide to Sorting using Hibernate
- Guide to Pagination with Hibernate
- Guide to Hibernate Interceptors
- Guide to Hibernate Search
- Batch Processing with Hibernate/JPA