Home » Tag Archives: JBoss Hibernate

Tag Archives: JBoss Hibernate

Use stored procedures with Hibernate

jboss-hibernate-logo

This article show different ways to call stored procedures from hibernate. JDBC actions will not be covered. Postgresql will be used as a database. CREATE DATABASE example; CREATE TABLE company ( company_id BIGSERIAL PRIMARY KEY, name TEXT NOT NULL ); CREATE TABLE benefit ( benefit_id BIGSERIAL PRIMARY KEY, name TEXT, company_id BIGINT, CONSTRAINT fk_company FOREIGN KEY (company_id) REFERENCES company (company_id) ...

Read More »

Hibernate: use join table alias on sqlRestriction

jboss-hibernate-logo

When using hibernate in case of complex queries there is the need to use sql. Therefore sqlRestrictions come to the rescue. However using sql restrictions on join table alias is a bit tricky. There would be three tables: The company table. The employee table. Each employee belongs to one company therefore we have a many to one relationship. The benefit ...

Read More »

7 ways to improve performance of a Hibernate application

jboss-hibernate-logo

Hibernate is a great tool for integrating Java web applications with a SQL database, but what should we do when the application’s response times start increasing considerably? What should we do when we’re getting doubts whether the application will scale with the growth of our customer base? Before spending a fortune on hosting or rewriting the code, consider analysing and improving these 7 areas of your web application. #1 Tuning JVM memory settings The JVM ...

Read More »

Using Hibernate Bean Validator in Java SE

jboss-hibernate-logo

The main Bean Validation page states that “Bean Validation is a Java specification which … runs in Java SE but is integrated in Java EE (6 and 7).” This post demonstrates using Java Bean Validation reference implementation (Hibernate Validator) outside of a Java EE container. The examples in this post are based on Hibernate Validator 5.1.3 Final, which can be ...

Read More »

How does Hibernate Query Cache work

jboss-hibernate-logo

Introduction Now that I covered both Entity and Collection caching, it’s time to investigate how Query Caching works. The Query Cache is strictly related to Entities and it draws an association between a search criteria and the Entities fulfilling that specific query filter. Like other Hibernate features, the Query Cache is not as trivial as one might think. Entity model ...

Read More »

Custom Boolean User Type with Hibernate JPA

jboss-hibernate-logo

The ANSI SQL 1999 standard introduced a BOOLEAN data type (although unfortunately only as an optional feature). But to date it still isn’t implemented by most major database systems. As a consequence boolean columns are implemented in various ways. E.g., CHAR columns containing ‘Y’ or ‘N’, or using BIT columns. Subsequently, there is no way for JPA to provide a ...

Read More »

How does Hibernate READ_WRITE CacheConcurrencyStrategy work

jboss-hibernate-logo

Introduction In my previous post, I introduced the NONSTRICT_READ_WRITE second-level cache concurrency mechanism. In this article, I am going to continue this topic with the READ_WRITE strategy. Write-through caching NONSTRICT_READ_WRITE is a read-through caching strategy and updates end-up invalidating cache entries. As simple as this strategy may be, the performance drops with the increase of write operations. A write-through cache ...

Read More »

How does Hibernate NONSTRICT_READ_WRITE CacheConcurrencyStrategy work

jboss-hibernate-logo

Introduction In my previous post, I introduced the READ_ONLY CacheConcurrencyStrategy, which is the obvious choice for immutable entity graphs. When cached data is changeable, we need to use a read-write caching strategy and this post will describe how NONSTRICT_READ_WRITE second-level cache works. Inner workings When the Hibernate transaction is committed, the following sequence of operations is executed: First, the cache ...

Read More »

How does Hibernate Collection Cache work

jboss-hibernate-logo

Introduction Previously, I described the second-level cache entry structure, Hibernate uses for storing entities. Besides entities, Hibernate can also store entity associations and this article will unravel the inner workings of collection caching.       Domain model For the up-coming tests we are going to use the following entity model: A Repository has a collection of Commit entities: @org.hibernate.annotations.Cache( ...

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.