Home » Tag Archives: JBoss Hibernate (page 3)

Tag Archives: JBoss Hibernate

A beginner’s guide to JPA and Hibernate Cascade Types

jboss-hibernate-logo

Introduction JPA translates entity state transitions to database DML statements. Because it’s common to operate on entity graphs, JPA allows us to propagate entity state changes from Parents to Child entities. This behavior is configured through the CascadeType mappings. JPA vs Hibernate Cascade Types Hibernate supports all JPA Cascade Types and some additional legacy cascading styles. The following table draws ...

Read More »

Hibernate Locking Patterns – How does PESSIMISTIC_READ and PESSIMISTIC_WRITE work

jboss-hibernate-logo

Introduction Java Persistence API comes with a thorough concurrency control mechanism, supporting both implicit and explicit locking. The implicit locking mechanism is straightforward and it relies on: Optimistic locking: Entity state changes can trigger a version incrementation Row-level locking: Based on the current running transaction isolation level, the INSERT/UPDATE/DELETE statements may acquire exclusive row locks While implicit locking is suitable ...

Read More »

JPA 2.1 criteria delete/update and temporary tables in Hibernate

jboss-hibernate-logo

Since JPA version 2.0 the EntityManager offers the method getCriteriaBuilder() to dynamically build select queries without the need of string concatenation using the Java Persistence Query Languge (JPQL). With version 2.1 this CriteriaBuilder offers the two new methods createCriteriaDelete() and createCriteriaUpdate() that let us formulate delete and update queries using the criteria API. For illustration purposes lets use a simple ...

Read More »

Hibernate locking patterns – How does PESSIMISTIC_FORCE_INCREMENT Lock Mode work

jboss-hibernate-logo

Introduction In my previous post, I introduced the OPTIMISTIC_FORCE_INCREMENT Lock Mode and we applied it for propagating a child entity version change to a locked parent entity. In this post, I am going to reveal the PESSIMISTIC_FORCE_INCREMENT Lock Mode and compare it with its optimistic counterpart. More alike than different As we already found out, the OPTIMISTIC_FORCE_INCREMENT Lock Mode can ...

Read More »

Hibernate locking patterns – How does OPTIMISTIC_FORCE_INCREMENT Lock Mode work

jboss-hibernate-logo

Introduction In my previous post, I explained how OPTIMISTIC Lock Mode works and how it can help us synchronize external entity state changes. In this post, we are going to unravel the OPTIMISTIC_FORCE_INCREMENT Lock Mode usage patterns. With LockModeType.OPTIMISTIC, the locked entity version is checked towards the end of the current running transaction, to make sure we don’t use a ...

Read More »

NoSQL with Hibernate OGM – Part two: Querying for your data

jboss-hibernate-logo

After the first final version of Hibernate OGM came out end of January the team has been busy crafting a series of tutorial-style blogs which give you the chance to start over easily with Hibernate OGM. The fist part was all about getting setup and persisting your first entity. In this second part you’re going to learn how to query ...

Read More »

Hibernate locking patterns – How does Optimistic Lock Mode work

jboss-hibernate-logo

Explicit optimistic locking In my previous post, I introduced the basic concepts of Java Persistence locking. The implicit locking mechanism prevents lost updates and it’s suitable for entities that we can actively modify. While implicit optimistic locking is a widespread technique, few happen to understand the inner workings of explicit optimistic lock mode. Explicit optimistic locking may prevent data integrity ...

Read More »

NoSQL with Hibernate OGM – Part one: Persisting your first Entities

jboss-hibernate-logo

The first final version of Hibernate OGM is out and the team recovered a bit from the release frenzy. So they thought about starting a series of tutorial-style blogs which give you the chance to start over easily with Hibernate OGM. Thanks to Gunnar Morling ( @gunnarmorling) for creating this tutorial. Introduction Don’t know what Hibernate OGM is? Hibernate OGM ...

Read More »

Leaky Abstractions, or How to Bind Oracle DATE Correctly with Hibernate

jboss-hibernate-logo

We’ve recently published an article about how to bind the Oracle DATE type correctly in SQL / JDBC, and jOOQ. This article got a bit of traction on reddit with an interesting remark by Vlad Mihalcea, who is frequently blogging about Hibernate, JPA, transaction management and connection pooling on his blog. Vlad pointed out that this problem can also be ...

Read More »

Hibernate collections optimistic locking

jboss-hibernate-logo

Introduction Hibernate provides an optimistic locking mechanism to prevent lost updates even for long-conversations. In conjunction with an entity storage, spanning over multiple user requests (extended persistence context or detached entities) Hibernate can guarantee application-level repeatable-reads. The dirty checking mechanism detects entity state changes and increments the entity version. While basic property changes are always taken into consideration, Hibernate collections ...

Read More »
Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.