Home » Tag Archives: JBoss Hibernate

Tag Archives: JBoss Hibernate

One-shot Delete with Hibernate (JPA)

jboss-hibernate-logo

In older versions of Hibernate, I can see the one-shot delete indicated in the manual. But newer versions no longer have this section. I’m not sure why. So, in this post, I take a look if it still works. The one-shot delete section says: Deleting collection elements one by one can sometimes be extremely inefficient. Hibernate knows not to do ...

Read More »

Custom Audit Log With Spring And Hibernate

jboss-hibernate-logo

If you need to have automatic auditing of all database operations and you are using Hibernate…you should use Envers or spring data jpa auditing. But if for some reasons you can’t use Envers, you can achieve something similar with hibernate event listeners and spring transaction synchronization. First, start with the event listener. You should capture all insert, update and delete ...

Read More »

Spring-Managed Hibernate Event Listeners

jboss-hibernate-logo

Hibernate offers event listeners as part of its SPI. You can hook your listeners to a number of events, including pre-insert, post-insert, pre-delete, flush, etc. But sometimes in these listeners you want to use spring dependencies. I’ve written previously on how to do that, but hibernate has been upgraded and now there’s a better way (and the old way isn’t ...

Read More »

5 Common Hibernate Exceptions and How to Fix Them

jboss-hibernate-logo

See how you can easily solve the most common issues with Hibernate Hibernate is probably the most popular JPA implementation on the market and you can see that in many places, like: The number of projects in which you’ve used it yourself, The number of job positions which ask for Hibernate experience and of course The number of questions and ...

Read More »

How to handle Stop Words in Hibernate Search 5.5.2 / Apache Lucene 5.4.x?

apache-lucene-logo

The Stop Words like [“a”, “an”, “and”, “are”, “as”, “at”, “be”, “but”, “by”, “for”, “if”, “in”, “into”, “is”, “it”, “no”, “not”, “of”, “on”, “or”, “such”, “that”, “the”, “their”, “then”, “there”, “these”, “they”, “this”, “to”, “was”, “will”, “with”] and the existence of them in terms or database or files that are to be indexed/searched by lucene can lead to any of ...

Read More »

Enabling Entity and Query cache in Hibernate

jboss-hibernate-logo

1. Introduction Amongst the performance related tasks I have been through, this has been one of them. The concern is that if the same query is invoked every time for a particular entity and the table data is not liable to change for a particular time slot, we can possibly cache the query results with Hibernate. This means that, if we want the details ...

Read More »

Setting Up Distributed Infinispan Cache with Hibernate and Spring

jboss-hibernate-logo

A pretty typical setup – spring/hibernate application that requires a distributed cache. But it turns out not so trivial to setup. You obviously need cache. There are options to do that with EhCache, Hazelcast, Infinispan, memcached, Redis, AWS’s elasticache and some others. However, EhCache supports only replicated and not distributed cache, and Hazelcast does not yet work with the latest ...

Read More »

One to many XML mapping in Hibernate

jboss-hibernate-logo

One to many relationship states that a single instance of an entity is associated with multiple instances of the another entity. In other words, each record in one of the tables is associated with multiple records in the other table. Let us check out how we can define such relationship in Hibernate through XML mapping file. 1. Entity Relationship Diagram Assuming ...

Read More »

Rapid Development with Hibernate in CQRS Read Models

jboss-hibernate-logo

In this post I’m going to share a few tricks for using Hibernate tooling in CQRS read models for rapid development. Why Hibernate? Hibernate is extremely popular. It’s also deceptively easy on the outside and fairly complex on the inside. It makes it very easy get started without in-depth understanding, misuse, and discover problems when it’s already too late. For ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns