JPA 2.1 quick and easy to understand tutorials.
Quick introduction to JPA with a kick-start standalone example.
Understanding different requirements and features of entity class.
Understanding concepts of persistence-context and persistence-unit.
What are basic Java persistable types and what SQL types they are converted to?
How enums are persisted by default and how to customize the persistence by using @Enumerated annotation.
@Temporal Annotation Example.
How different strategies can be selected for primary key generation.
What are @SequenceGenerator and @TableGenerator?. Examples of @SequenceGenerator.
How @TableGenerator is different from @SequenceGenerator? @TableGenerator Examples.
How JPA runtime accesses and initializes our entities? Understanding default access type and customizing it by using @Access annotation.
Mapping one-to-one association of Java entities to database tables by using @OneToOne.
Using an intermediate table to persis one-to-one relationship.
Mapping a bidirectional one-to-one object association to database tables.
Using an intermediate table for bidirectional one-to-one association
Sharing a single instance of the target entity among multiple instances of the source entities by using @ManyToOne.
Persisting a collection of the target entity by using @OnToMany.
How to customize generation or mapping of an existing join table for @OneToMany relationship using @JoinTable annotation?
Using a foreign key column in the target table instead of an intermediate join table to persist one-to-many association.
Using combination of @OneToMany and @ManyToOne to have one-to-many bidirectional and many-to-one bidirectional relationships.
Using an intermediate join table to map bidirectional OneToMany/ManyToOne relationship.
Mapping many-to-many association of Java entities to database tables by using @ManyToMany annotation.
Mapping bidirectional ManyToMany association by using @ManyToMany on both sides.
What are embeddable classes? How they are mapped to database tables? @Embeddable and @Embedded example.
How to include an embeddable class within another embeddable class?
Example of an @Embeddable class having a ManyToOne relationship with an entity.
Example of an @Entity class having multiple references of the same @Embeddable class.
Example of an @Entity class having multiple references of the same @Embeddable class which has a relationship with another entity.
How to persist a basic type collection in JPA?
Persisting a collection embeddable type collection
Using @CollectionTable with @ElementCollection.
How to persist java.util.Map for the basic key/value types?
Using @MapKeyColumn, @CollectionTable and @Column along with ElementCollection to customize java.util.Map mapping.
How to persist a java.util.Map of basic types keys and embeddable values?
How to persist a java.util.Map of basic types keys and entity values?
How to persist a java.util.Map of @Embeddable keys and basic type values?
How to persist a java.util.Map of @Entity keys and basic type values?
How to persist a java.util.Map of @Entity keys and @Entity values?
Mapping inheritance hierarchy to a single table.
Mapping inheritance hierarchy to joined tables.
Mapping inheritance hierarchy to separate tables.
@MappedSuperclass example
Non-Entity Classes in the Entity Inheritance Hierarchy.
@IdClass example.
@EmbeddedId example.
Using a composite key with @IdClass which has a derived identity coming from @OneToOne.
Using a composite key with @EmbeddedId having a derived identity of a @OneToOne relationship.
Using a composite key with @IdClass which has a derived identity coming from @ManyToOne.
Using a composite key by using @EmbeddedId which has a derived identity coming from @ManyToOne.
The target of @ManyToOne having composite key defined with @IdClass.
@Lob annotation example.
@OrderColumn Example
Ordering query results by using @OrderBy
What is cascading and how to use it?
Understanding Lazy Fetching
Applying unique constraints using @Table annotation
@Column#unique Example
EntityManager#persist() Example
EntityManager#remove() Example
EntityManager#flush() Example
EntityManager#refresh() Example
Understanding detached entity. Manually detaching entities with EntityManager#detach().
Synchronizing detach entity state with EntityManager#merge()
How to load lazy relationships of detached entities?
EntityManager.getReference() Example
EntityManager.getReference() and @OneToOne example.
EntityManager.getReference() and @ManyToOne example.
EntityManager.contains() Examples
PersistenceUtil.isLoaded() Examples
Using PersistenceUtil.isLoaded() and EntityManager.contains() to initialize detached lazy entity?
What is optimistic locking? How to use @Version annotation?
Understanding OptimisticLockException and producing it.
How version attribute is affected while updating entity relationships?
LockModeType enum and the API to set them.
OPTIMISTIC_FORCE_INCREMENT Example
OPTIMISTIC_FORCE_INCREMENT use case Example
Pessimistic Example
Example of multiple threads using PESSIMISTIC_READ simultaneously?
PessimisticLockException handling. Setting javax.persistence.lock.timeout
How to define listeners to have callbacks on entity operations?
How to persist date created and date modified using entity callback listener?
How to define listeners by using @EntityListeners?
How to persist date created and date modified using @EntityListeners?
How to use Java Bean validation annotations on JPA entities?
Understanding Entity Graphs with examples
@NamedSubgraph Example.
AttributeConverter, @Converter and @Converter Example.
Using @Convert#attributeName on an embedded attribute.
Conversion of map key/value example.
Converter#autoApply=true example.
Second-Level Cache Example.
Using Cache Interface.
shared-cache-mode=ENABLE_SELECTIVE example.
shared-cache-mode=DISABLE_SELECTIVE example.
shared-cache-mode=UNSPECIFIED example.
retrieveMode=CacheRetrieveMode.BYPASS example.
storeMode=CacheStoreMode.BYPASS/REFRESH examples.
Getting started with JPQ with SELECT-FROM-WHERE Query example.
ORDER BY ASC/DESC Clause Example
SELECT-DISTINCT Example
Literals Examples
INNER JOIN Examples
LEFT OUTER JOIN Example
ON clause of LEFT OUTER JOIN EXAMPLE
JPQL FETCH JOIN Query Example.
Using BETWEEN clause.
Using JPQL IN expression.
Using LIKE expressions.
Using 'IS NULL'.
Using 'IS EMPTY'
Using 'MEMBER OF'.
Using aggregate function in SELECT.
GROUP BY and HAVING Examples
Subqueries examples.
Exists Expression Example.
Using All and ANY expressions.
Understanding polymorphic queries.
TREAT operator Example
String functions examples.
Arithmetic functions examples.
CURRENT_DATE, CURRENT_TIME and CURRENT_TIMESTAMP examples.
Calling native database function from JPQL.
Different scenarios to execute queries involving collections in WHERE clause.
Case expression example.
Updating entities via JPQL update statements
Deleting entities by using DELETE queries.
Type-safe queries with TypedQuery
Constructor Expressions Example
Tuple example in JPQL
Use of KEY, VALUE, ENTRY examples in JPQL
@NamedQuery Example
Using EntityManager#createStoredProcedureQuery() to create StoredProcedureQuery.
Calling Oracle Stored Procedure involving Ref Cursor
Getting result set from HSQLDB's cursor
Using StoredProcedureQuery to call Hsqldb function
@NamedStoredProcedureQuery + Oracle REF_CURSOR Example
Select example.
Understanding Metamodel with example.
Ordering the query results by using Criteria API
Selection Other Than Entities
CriteriaBuilder#construct() Example
Tuple Example
Distinct example
ParameterExpression Example
Selection#alias() Example.
Inner Join Example
Outer Join Example
'On' Condition Example
Fetch Joins in Criteria API Example
MapJoin Examples
Path Navigation in Criteria API
Applying where clause API reference
CriteriaBuilder.between() Examples
isEmpty() and isNotEmpty() Examples
isMember() and isNotMember() Examples
CriteriaBuilder#like() and CriteriaBuilder#notLike() Examples
Expression.isNull() and Expression.isNotNull() Examples
Expression.in() Examples
CriteriaBuilder#treat() Example
The aggregation methods avg, max, min, sum, count Examples
GroupBy And Having methods examples
Mapping GROUP BY and HAVING result to user defined object
CriteriaQuery.subquery() examples.
Subquery.correlate() Example
CriteriaBuilder.exists() Example
CriteriaBuilder.all(), CriteriaBuilder.any() and CriteriaBuilder.some() examples
CriteriaBuilder String manipulation API
JPA arithmetic operations in CriteriaBuilder
The size() and index() methods in JPA Criteria API
Examples of Date Time methods in CriteriaBuilder
CriteriaBuilder.function() Example
CriteriaBuilder.selectCase() Examples
Updating with CriteriaUpdate
Using CriteriaDelete
Query Modification
JPA + Hibernate + Oracle Database