@JoinColumn Annotation Explained 1. Introduction The annotation javax.persistence.JoinColumn marks a column for as a join column for an entity association or an element collection. In this quick tutorial, we’ll show some examples of basic @JoinCloumn usage. 2. @OneToOne Mapping Example The @JoinColumn annotation combined with a @OneToOne mapping indicates that a given column… Continue Reading jpa-join-column

Spring, Hibernate and a JNDI Datasource 1. Overview In this article, we’ll create a Spring application using Hibernate/JPA with a JNDI datasource. If you want to rediscover the basics of Spring and Hibernate, check out this article. 2. Declaring the Datasource ==== 2.1. System Since we’re using a JNDI datasource,… Continue Reading spring-persistence-jpa-jndi-datasource

Transactions with Spring and JPA 1. Overview This tutorial will discuss the right way to configure Spring Transactions, how to use the @Transactional annotation and common pitfalls. For a more in-depth discussion on the core persistence configuration, check out the Spring with JPA tutorial. Basically, there are two distinct ways… Continue Reading transaction-configuration-with-jpa-and-spring

Hibernate Interceptors 1. Overview In this discussion, we’ll look at various ways of intercepting operations within Hibernate’s abstracted relational mapping implementation. 2. Defining Hibernate Interceptors The Hibernate Interceptor is an interface that allows us to react to certain events within Hibernate. These interceptors are registered as callbacks and provide communication… Continue Reading hibernate-interceptor

Auditing with JPA, Hibernate, and Spring Data JPA 1. Overview In the context of ORM, database auditing means tracking and logging events related to persistent entities, or simply entity versioning. Inspired by SQL triggers, the events are insert, update and delete operations on entities. The benefits of database auditing are… Continue Reading database-auditing-jpa

Hibernate Tips Book Excerpt: How to Map an Inheritance Hierarchy to One Table Persistence Hibernate 1. Introduction Inheritance is one of the key concepts in Java. So, it’s no surprise that most domain models use it. But unfortunately, this concept doesn’t exist in relational databases, and you need to find… Continue Reading hibernate-tips-how-to-map-an-inheritance-hierarchy-to-one-table