Hibernate Basics

logo

How to Remove Orphan Entities in Hibernate?

In Hibernate, an orphan entity refers to a child entity that has been disassociated from its parent. If these orphan entities are not explicitly removed, they remain in the database and result in unwanted data. The orphanRemoval = true attribute on the mapping annotation on parent entity automatically removes the child entities from the database …

Mocking an In-memory JNDI DataSource

Learn to create and inject an in-memory DataSource that can be used to mock J2EE container provided JNDI DataSource without running a server.

Batch Processing with Hibernate/JPA

Learn to execute bulk SQL INSERT and UPDATE statements using Hibernate / JPA batch processing, and to configure session-specific batch sizes.

Stored Procedures with Hibernate

Hibernate provides support for executing the stored procedures and capturing their outputs using StoredProcedureQuery and ProcedureCall APIs.

Guide to Hibernate Search

Learn to configure full text and query index-based searches in Hibernate using backends like Lucene, Elasticsearch or OpenSearch.

Guide to Hibernate Interceptors

Learn to use Hibernate Interceptor for getting callbacks for persistence events and register it with Session and SessionFactory interfaces.

Guide to Pagination with Hibernate

Learn to implement and test the pagination functionality in hibernate using the HQL setFirstResult(), setMaxResults() and ScrollableResults.

Guide to Sorting using Hibernate

Learn to sort the entities fetched from the database using hibernate HQL, native SQL, Criteria queries and Comparator interface.

Deleting Entities with Hibernate

Learn to delete a single entity or a list of entities matching some criteria using hibernate native APIs and Jakarta persistence APIs.

Hibernate @NamedStoredProcedureQuery

Learn to execute SQL stored procedures with the help of @NamedStoredProcedureQuery annotation from Jakarta persistence API that helps in specifying the name of a stored procedure, its parameters, and its result type. 1. Project Setup The support for executing stored procedures using @NamedStoredProcedureQuery has been added in JPA 2.1. So …

Guide to Lazy Loading in Hibernate

Hibernate fetches data from the database either in eager or lazy mode. Lazy loading refers to a strategy when data is loaded on demand.

Cascade Types in JPA and Hibernate

Learn JPA Cascade Types and how they are related to Hibernate Cascade Types. Learn how to control the orphan removal with an example.

Hibernate Named Query Examples

Learn to create, group and execute named HQL and named native SQL queries in Hibernate using @NamedQuery and @NamedNativeQuery annotations.

Inserting Objects with Hibernate

Learn to insert an object into the database using hibernate’s Session interface, JPA’s EntityManager and HQL Query interface with examples.

Hibernate Hello World Example

Step by step hibernate hello world example with maven and eclipse. Learn to create, configure and store hibernate 5 entities in the database.

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.