How to combine the Hibernate assigned generator with a sequence or an identity column

Introduction The entity identifier can either be manually assigned, or it can be automatically generated by an identity column or a database sequence. In this post, I’ll show you how you can mix the assigned generator with an identity column or a database sequence.

High-Performance Java Persistence – Chapter 14 – Batching

Part 2, Chapter 14 Every new chapter of my book is released right after it’s being completed, so the reader doesn’t have to wait for the whole part to be finished to get access to new material. Table of content This chapter explains how batch updates work in Hibernate.

MySQL metadata locking and database transaction ending

Introduction As previously explained, every SQL statement must be executed in the context of a database transaction. For modifying statements (e.g. INSERT, UPDATE, DELETE), row-level locks must be taken to ensure recoverability and avoid the data anomalies. Next, I’ll demonstrate what can happen when a database transaction is not properly ended.

High-Performance Java Persistence – Chapter 13 – Flushing

Part 2, Chapter 13 Every new chapter of my book is released right after it’s being completed, so the reader doesn’t have to wait for the whole part to be finished to get access to new material. Table of content This chapter explains the inner-workings of the Hibernate Persistence Context implementation.

How to enable bytecode enhancement dirty checking in Hibernate

Introduction Hibernate runs the automatic dirty checking mechanism during flush-time, and any managed entity state change is translated into an UPDATE SQL statement. The default dirty checking mechanism uses Java reflection and goes through every property of every managed entity. If the Persistence Context has few entities, this process might go unnoticed, but, if we’re dealing with many entities or the entities have many properties (e.g. a legacy database Domain Model mapping), then the reflection-based dirty checking might have an associated performance impact.

High-Performance Java Persistence – Chapter 12 – Inheritance

Part 2, Chapter 12 Every new chapter of my book is released right after it’s being completed, so the reader doesn’t have to wait for the whole part to be finished to get access to new material. Table of content This chapter explains JPA inheritance from a data access performance point of view.

How do JPA and Hibernate define the AUTO flush mode

Introduction The Persistence Context acts as a transactional-write behind cache for the incoming entity state transitions, and all changes are synchronized with the database during flushing. Although both the Hibernate Session and the JPA EntityManager define a flush() method to manually trigger this process, it’s much more convenient to let Hibernate manage the Persistence Context flushing. Unfortunately, there’s is a major difference between how JPA and Hibernate define the automatic flushing mechanism.

High-Performance Java Persistence – Chapter 11 – Relationships

Part 2, Chapter 11 Every new chapter of my book is released right after it’s being completed, so the reader doesn’t have to wait for the whole part to be finished to get access to new material. Table of content This chapter explains JPA relationships from a data access performance point of view.

How does aggressive connection release work in Hibernate

Hibernate connection providers Hibernate needs to operate both in Java EE and stand-alone environments, and the database connectivity configuration can be done either declaratively or programmatically. To accommodate JDBC Driver connections as well as RESOURCE_LOCAL and JTA DataSource configurations, Hibernate defines its own connection factory abstraction, represented by the org.hibernate.engine.jdbc.connections.spi.ConnectionProvider interface.

High-Performance Java Persistence – Chapter 10 – Mapping Types and Identifiers

Part 2, Chapter 10 Every new chapter of my book is released right after it’s being completed, so the reader doesn’t have to wait for the whole part to be finished to get access to new material. Table of content This chapter explains the core mapping elements used by Hibernate and details the basic type and the identifier generators.