Red Hat

In Relation To

The Hibernate team blog on everything data.

Hibernate Community Newsletter 24/2016

Posted by    |       |    Tagged as Discussions Hibernate ORM

Welcome to the Hibernate community newsletter in which we share blog posts, forum, and StackOverflow questions that are especially relevant to our users.


Don’t miss our Hibernate developer interviews with Christian Beikov and Simon Martinelli.

If you like our interviews, then we have good news since we are going to interview many developers that are a constant inspiration for our Java community.


If you plan on using Apache Ignite, check out this article about using Hibernate OGM when operating with a JPA-based Domain Model.

Database streaming is usually associated with large data set processing. However, there is a price to pay for using streaming. This article explains why pagination might be a better option in many batch processing use cases.

Blaze Persistence offers many complementary features to standard JPA Criteria API. In this post, Christian Beykov explains why you should use Entity Views when fetching data.

Flemming Harms wrote a very good article about integrating JPA with Apache Camel.

Thorben Janssen shows you how you can generate the database schema from JPA entities. While this is fine for generating an initial migration script, in reality, you need incremental migration scripts that are managed by a tool like Flyway. Check out this article for more info.

Multitenancy is a very powerful concept, and JavaEE 8 might standardize this technique. Meanwhile, you can use Hibernate ORM as explained in this article.

IntelijIDEA 2016.3 offers a very nice console for running JPQL queries and visualizing query results. Check out this article for more info.

In this post, I’d like you to meet Simon Martinelli, who, among many other things, is teaching Java EE and JPA at the University of Applied Sciences in Berne.

Simon Martinelli, align=
  1. Hi, Simon. Would you like to introduce yourself and tell us a little bit about your developer experience?

    I’m a software architect, developer, and trainer from Switzerland working for simas GmbH. Besides that, I’m a lecturer for Java EE, architecture and design and persistence technologies at the University of Applied Sciences in Berne. In my spare time, I’m working on some open source projects and as I’m an expert group member of JSR 352 Batch and JSR 354 Money and Currency API.

    I started my IT career in 1995 as a Cobol developer on IBM mainframe. Since 2000, I’ve been working in many enterprise projects as a developer, architect, and technical lead, using J2EE/Java EE, Spring framework, and from time to time .NET. My first contact with OR-Mapping was in 2000 when we used TopLink in a project for Swiss Railways.

  2. You have an open-source project on GitHub called Query Language Result Mapper. Can you tell us what’s the goal of this framework?

    I love the JPA constructor expression. In my opinion, it’s the best way to get around the common performance problems when using JPA in a naive way. But the constructor expression only works with JPQL or Criteria API and sometimes you need to execute a SQL query but don’t want to use a fully featured SQL framework like jOOQ.

    Sure, JPA comes with the ConstructorResult but I find it too complicated, and it was not available with JPA 1.0. Hibernate has the ResultTransformer, but this only works with Hibernate. So I decided to start Query Language Result Mapper (QLRM).

    QLRM simply tries to find a matching constructor based on a JPA native query result or, when using plain JDBC, a JDBC ResultSet. It’s simple, small and not related to a specific JPA implementation.

  3. You are also teaching Java EE and Java Persistence API at the University of Applied Science in Berne. Is JPA easy to learn? What do your students think of this Java Persistence standard?

    JPA is by far the most complicated part of Java EE to learn. Because it’s leaky abstraction, you have to know a lot about SQL databases and what’s going on behind the scenes. It’s also the most common source of performance problems. While teaching, I always try to focus on how to avoid these performance problems.

    My students usually like JPA because it makes data access much easier. For those who don’t know the history of OR-Mapping, it’s hard to understand that the JPA implementation behaves differently in some situations. What they don’t like is that (currently) JPA does not support the Java 8 Date Time API.

  4. Since I started blogging, I realized that explaining a subject helps me better understand it. Do you think all developers should be involved in teaching or writing articles or books about the subjects they want to master?

    Absolutely! I’m teaching JPA since 2007, and this forces me to get a deep understanding of the topic because the questions of the students can be very challenging. Sometimes I even have to look at the code of the JPA implementation to understand what happens under the hood. In return, this know-how helps me to write better and faster applications.

    As Albert Einstein said: "If you can’t explain it simply, you don’t understand it well enough."

  5. We always value feedback from our users, so can you tell us what you’d like us to improve or are there features that we should add support for?

    I think the whole Hibernate team is doing a great job! It’s more than feature-complete (it’s hard to know every feature, though).

    Just one minor thing: When reading the documentation it’s often hard to differentiate what’s JPA standard and what’s Hibernate specific. But I don’t think that this is very important because not many developers are switching the JPA implementation in a project.

Thank you, Simon, for taking your time. It is a great honor to have you here. To reach Simon, you can follow him on Twitter.

Today we are releasing two new versions of Hibernate Search: 5.6.0.Beta4 and 5.7.0.Beta1!

Version 5.6.0.Beta4 brings the latest bugfixes and previously missing features for our experimental Elasticsearch integration. This is the version to use with Hibernate ORM versions 5.0.x and 5.1.x.

Version 5.7.0.Beta1 brings the exact same changes as 5.6.0.Beta1, but on top of the compatibility with Hibernate ORM version 5.2.x that was introduced with 5.7.0.Alpha1.

What’s new?

  • HSEARCH-402: A new async reader strategy has been added for the Lucene indexing service, bringing performance boosts when you are okay with your queries being run on an out-of-date index (how much out-of-date is configurable).

  • HSEARCH-2260: A new VALIDATE index schema management strategy has been added for Elasticsearch, allowing you to automatically check on startup that your Hibernate Search mappings are in line with the Elasticsearch mappings.

  • Issues with @IndexedEmbedded in the Elasticsearch integration have be addressed: everything should now work properly, with the notable exception of @IndexedEmbedded.indexNullAs (not to be confused with @Field.indexNullAs).

  • HSEARCH-2235: You can now configure Hibernate Search to send requests to Elasticsearch servers in round-robin, enabling load-balancing. Failover is not supported yet, but we’ll be working on it.

  • HSEARCH-2360: Elasticsearch projections now use source filtering, greatly reducing the bandwidth needs when retrieving results.

  • We now test our Elasticsearch integration against version 2.4.2, which fixed an issue with date formats that impacted Hibernate Search. We strongly recommend to update your 2.4.x instances to the lastest available version in the 2.4.x series.

  • …​ and much more. The full change log can be found on our JIRA instance or on our GitHub repository.

When will this 5.6.0 be released?

We’ve been caught up in the polishing work with the Elasticsearch integration lately, but we’re seeing the end of the tunnel: the list of open tasks is getting shorter and shorter. The first release candidate for Hibernate Search 5.6.0 will land by the end of next week.

So, if you haven’t tested 5.6 already, now’s the time! Should you find any bug, please report them on our JIRA instance.

What about Elasticsearch 5 support?

Please be aware that we’re not currently supporting Elasticsearch 5.x. The main reason is it brings several backward-incompatible changes that would require quite a bit of work if we still want to support the 2.x series. And we don’t want to postpone the Hibernate Search 5.6.0 release any more.

Our plan is to release a 5.6.0 supporting Elasticsearch 2.x, and add Elasticsearch 5 support in Hibernate Search 6.0 or, maybe, in an early 5.8 release. You may refer to HSEARCH-2434 to track the status of Elasticsearch 5.0 support.

When will 5.7.0 be released?

Everything is going smoothly with this version, and very few bugs have been reported. As soon as 5.6.0 will be released, we’ll publish the candidate release for 5.7.0.

How to get these releases

All versions are available on Hibernate Search’s web site.

Ideally use a tool to fetch it from Maven central; these are the coordinates:


Or, for Hibernate Search 5.7:


To use the experimental Elasticsearch integration you’ll also need:


(Change the version to 5.7.0.Beta1 in order to test the Elasticsearch integration within Hibernate Search 5.7)

Downloads from Sourceforge are available as well.

Fifth bug-fix release for ORM 5.2

Posted by    |       |    Tagged as Hibernate ORM Releases

The Fifth bug-fix release for Hibernate ORM 5.2 has just been published. It is tagged at

The complete list of changes can be found here (or here for people without a Hibernate Jira account).

For information on consuming the release via your favorite dependency-management-capable build tool, see

The release bundles can be obtained from SourceForge or BinTray.

Meet Christian Beikov and Blaze Persistence

Posted by    |       |    Tagged as Discussions Hibernate ORM

In this post, I’d like you to meet Christian Beikov, who is one of the most active Hibernate contributors.

Christian Beikov, align=
  1. Hi, Christian. Would you like to introduce yourself and tell us a little bit about your developer experience?

    Hey, Vlad. My name is Christian Beikov, and I am 25. I’m living with my girlfriend in Vienna, the capital city of Austria. I started working with Java EE technologies in school and continued to do so at my first job where I am still employed part-time. Next to my job, I am doing my master studies in Software Engineering at TU Wien which I am hopefully finishing next year.

    My main interests are in distributed systems, database technologies and everything Java/JVM-related. In school, I came into contact with Java EE for the first time when I was by developing a JSF-based web app with Hibernate on top of GlassFish with NetBeans. When I started my job at Curecomp GmbH, I mainly worked with Eclipse and WebSphere and about 2 years ago, I managed to fully migrate the company’s development stack to WildFly and IntelliJ IDEA. During these migrations and the countless university assignment projects in which I have used Hibernate, I’ve stumbled upon one or another bug.

  2. You’ve been very active in the Hibernate ecosystem, sending Pull Requests and getting involved in future design discussions. How do you manage to blend the open-source involvement with your day job?

    The work I am doing in open-source projects happens mostly in my free time. I like to give back something to the community, even if it’s just bug reports. Since I use Hibernate in so many projects, I also see my contributions as an investment in improving the overall quality of the projects I do.

    At my day job, I am sometimes facing problems that I simply can’t workaround or doing a proper fix seems equally hard to me, which is how I justify fixing the Hibernate bug in the core. The deep knowledge that I gain from analyzing bugs and discussing features also helps me in my day job when reasoning about the behavior of Hibernate in certain situations which is a big plus.

  3. You are also developing Blaze Persistence. Can you tell us a little bit about this framework and how does it compare to Criteria API?

    Blaze-Persistence is a library on top of the JPA APIs. The core module provides a fluent query builder API that allows you to express queries in a Java DSL which should feel mostly intuitive. In addition to the standard features that are defined in JPA 2.1, it also implements support for some common functionality that already every JPA provider supports like for example aliasing fetch joins or entity joins. On top of that, Blaze-Persistence also provides deep integration with the JPA provider to support features like (recursive) CTEs or set operations like UNION, etc. Beware that the deep integration is currently only available for Hibernate since it is the provider I am mostly familiar with, but support for others is planned.

    One of the greatest features that Blaze-Persistence makes possible are Entity Views which are to JPA entities roughly what views are to tables in the RDBMS sense. An Entity View is an interface or abstract class that represents the structure of a projection for an entity. It’s basically the definition of a DTO, with the difference that you only need to specify getter methods along with the projection for that attribute as JPQL expression. When you then apply the Entity View on a base query, it will contribute the JPQL expressions as select items, thus creating an optimized JPQL and SQL query. The result of such a query, of course, is a list of objects that are a subtype of the Entity View. Apart from avoiding all the manual plumbing code to get the data into shape, you can make use of features like Collection mappings, Subviews or SubqueryProviders which let you define complex projections that one would normally not do.

    The Criteria API provided by JPA is hard to use as it requires a lot of typing and also some kind of skill. You need to know how to wire things up which is one of the big pain points that I tried to solve by introducing a fluent API. Sure the JPA Criteria API is type-safe, but that comes at the cost of obfuscating your query. A type-safe variant of the Blaze-Persistence core API or maybe even just some additional methods in the existing API are already on my roadmap, so I will also try to fill this gap while retaining readability.

    Since I don’t expect everyone to rewrite his existing JPA Criteria API based queries, I also implemented the JPA Criteria API on top of the Blaze-Persistence core API. You can even let your existing code build the queries with the JPA Criteria API and retrieve a Blaze-Persistence query builder from it. The resulting query builder can be used just like any other query builder which means you can use CTEs and all the other great features.

  4. Blaze Persistence works with any JPA provider. From your experience, how does Hibernate ORM compare to EclipseLink or OpenJPA?

    Just as a disclaimer, I haven’t dug too much into the communities of the other JPA providers as I don’t use them in any of my projects. Also, beware that I might be biased now since I know people from the Hibernate team and know who to contact if I have a problem, but I’ll try to be as neutral as possible.

    I got the feeling that the EclipseLink community didn’t care about the bugs I reported or forum posts I did, but apart from that, the implementation seems ok. It has some quirks like e.g. allowing lazy loading although the underlying entity manager is closed, but maybe that’s a feature :D

    DataNucleus which is one of the lesser known JPA providers is actually pretty good and the main developer there reacts super fast to bug reports. I found some bugs and also proposed some features to increase Hibernate compatibility and as far as I know, all of these issues have been resolved by now.

    I can’t tell you much about OpenJPA except that it seems rather dead or in maintenance mode only to me. The latest version is only JPA 2.0 compatible and unfortunately, lacks even proprietary ways to do certain things that are possible with other JPA providers.

    The thing I am mostly unsatisfied with is that most of the issues I found with any JPA provider are pretty basic things and should be asserted by the JPA TCK. I hope some Oracle guy who can actually do something reads this and pushes harder to make the JPA TCK open-source :)

  5. We always value feedback from our users, so can you tell us what you’d like us to improve or are there features that we should add support for?

    I think Hibernate already does a very good job. What I really would like to see is the decoupling of the SQL generation and execution from the ORM specifics. This is something I often would have needed in one way or another to workaround bugs or simply to execute the SQL that is needed for a specific task. Imagine you could specify a HQL query that just describes how the result mapping should be done, but specify your own SQL. This is something I am doing internally in Blaze-Persistence all the time for advanced queries. I hope the SQM feature that is planned for Hibernate 6 will allow me to do that so I can get rid of the dirty tricks I have to do right now to get stuff done.

Thank you, Christian, for taking your time. It is a great honor to have you here. To reach Christian, you can follow him on Twitter.

Hibernate ORM 5.1.3.Final

Posted by    |       |    Tagged as Hibernate ORM Releases

Hibernate ORM 5.1.3.Final has just been tagged and published.

The complete list of changes can be found here (or here for people without a Hibernate Jira account).

For information on consuming the release via your favorite dependency-management-capable build tool, see

The release bundles can be obtained from: SourceForge or BinTray.

Hibernate Validator 5.3.3.Final is out

Posted by    |       |    Tagged as Hibernate Validator Releases

A bugfix version for modular environments

Disclaimer: if you are not using a modular environment such as WildFly or OSGi, this release will probably be of little interest to you. But you can read this post anyway!

We are in the process of upgrading the Hibernate Validator version shipped with the WildFly application server. This 5.3.3.Final release is here to fix a bug exposed in the very flexible modular environment of WildFly.

If you have followed what we did for the 5.3.1.Final and the 5.3.2.Final releases, you know that we changed the way the javax.el.ExpressionFactory was managed. For the better.

But by doing so, we exposed a very well hidden bug in some specific WildFly environments. After some very fun class loading debugging, we ended up with a solution that fixes the issue at hand and also improves the user experience in OSGi environments.

You can find the complete list of all addressed issues (well, of the addressed issue) in the change log.

Getting the release

Hibernate Validator 5.3.3.Final is a drop-in replacement of Hibernate Validator 5.3.2.Final.

To get the release with Maven, Gradle etc. use the GAV coordinates org.hibernate:{hibernate-validator|hibernate-validator-cdi|hibernate-validator-annotation-processor}:5.3.3.Final.

Alternatively, a distribution bundle containing all the bits is provided on SourceForge (TAR.GZ, ZIP).

To get in touch, use the following channels:

What’s next?

We are going to prepare a 5.4 release with support for validation contributed by Lukas Niemeier and Willi Schönborn from Zalando and a lot of improvements to the annotation processor thanks to the great work of Marko Bekhta.

We are actively working on Bean Validation 2.0 and Hibernate Validator 6 with a strong focus on supporting the new features of Java 8 (and much more!). The more the merrier, so feel free to join us: drop ideas, comment on others' proposals, now is the time to define the future of Bean Validation. You can find all the necessary information on the Bean Validation website.

Hibernate Community Newsletter 23/2016

Posted by    |       |    Tagged as Discussions Hibernate ORM

Welcome to the Hibernate community newsletter in which we share blog posts, forum, and StackOverflow questions that are especially relevant to our users.


Don’t miss our Hibernate developer interviews with Rafael Winterhalter and Julien Dubois. If you like our interviews, then we have good news since we are going to interview many developers that are a constant inspiration for our Java community.

When streaming data from a Relational Database, it’s very important to understand the underlying JDBC Driver capabilities. Krešimir Nesek wrote a very good article about how you can take advantage of MySQL streaming when using Spring Data and Hibernate.

You should never concatenate strings when building dynamic queries, and this rule applies to JPQL queries as well. Check out this article for what dangers awaits you if you don’t follow this advice.

Nicky Bass Mølholm wrote a wonderful article explaining the benefit of using the newly introduced hibernate.jdbc.time_zone configuration property when using Spring Boot.

Matti Tahvonen has created Spring Boot example with Hibernate Spatial. You can check it out on GitHub.

Meet Rafael Winterhalter and Byte Buddy

Posted by    |       |    Tagged as Discussions Hibernate ORM

In this post, I’d like you to meet Rafael Winterhalter, Java Champion, JavaZone conference organizer, and Team Leader of Byte Buddy.

Rafael has done a great job migrating Hibernate from Javassist to Byte Buddy, for which we are very grateful.

Rafael Winterhalter, align=
  1. Hi, Rafael. Would you like to introduce yourself and tell us a little bit about your developer experience?

    Hei, I am Rafael, a native German who is living in Oslo, Norway where I work as a software consultant.

    Before that, I was in academia where I did a fair share of statistical analysis what evoked an interest in computer performance. After I left university, I have been working mostly with the JVM where I still enjoy working with performance critical systems but where I also do a lot of enterprise software development.

    I am also quite active in open source and as a conference speaker and organizer.

  2. You are the Team Leader of the Byte Buddy open-source framework. Can you tell what’s the goal of Byte Buddy?

    Byte Buddy originated out of frustration over cglib, a commonly used library for code generation that got abandoned a few years back. I was working on a proxy component that needed to retain the annotations of the proxied methods.

    Proxies are often implemented as subclasses where these annotations disappear as method annotations are never inherited. Many libraries such as Hibernate do however use annotations as part of their API what breaks this pattern. I got stuck and wrote a tiny library as a replacement for cglib which later evolved into what is Byte Buddy today.

    Today, the library‘s goal is to be the fastest and easiest way to define or modify Java classes at runtime. As a side goal, I wanted to offer some support for Android which was previously lacking a runtime code generation library and I wanted to make it easy to define Java agents.

  3. In 2013, you wrote the cglib: The missing manual article. How does Byte Buddy compare to cglib or javassist?

    I wrote this article as a heavy user of code generation libraries in open source and to share a bit of my knowledge of cglib which is not supplemented by any documentation. I still believe that this is one major issue of code generation libraries; due to the lack of documentation, many people fear using them for not understanding how they work despite their usefulness.

    Other than Byte Buddy, cglib is limited to creating subclasses of existing types where it can override existing methods. Byte Buddy gives you full freedom in defining additional fields or methods and allows you to implement methods arbitrarily. In practice, this often results in thinner byte code and better performance.

    Also, Byte Buddy does not require you to include any library-specific classes into the generated code what is crucial for OSGi-environments. Also, this will become a necessity when working with Java 9 modules which the authors of cglib did of course not anticipate 15 years back.

    Javassist has a proxy API that is similar to cglib which does, however, come with the identical limitations. Additionally, Javassist allows for arbitrary modifications of classes using a different API by supplying Java code as strings. While this approach gives you full freedom, it is very vulnerable to API-changes which then yield runtime errors and also opens up to code-injection when processing user input, similar to SQL-injection when using JDBC.

    Byte Buddy rather works with precompiled code which can be written in any JVM language and which can be inlined at runtime. Avoiding runtime compilation makes Byte Buddy’s transformations type-safe and much faster to apply at runtime.

  4. You have contributed to many open-source projects, Byte Buddy, Mockito, and now Hibernate ORM. Can you tell us more about the Hibernate and Byte Buddy integration?

    The usage of Byte Buddy in Hibernate ORM and Mockito differs a lot.

    Hibernate mostly uses code generation to implement runtime proxies. For the Hibernate enhancer, it does, however, require some rather fundamental changes of a code base by installing its own callbacks into classes in order to better monitor an object’s state. Fortunately, all such enhancement is done in a dedicated step what makes the code manipulation quite predictable.

    In Mockito, we traditionally only required simple subclass proxies. In Mockito 2, we added, however, a new mock maker that inlines the mocking logic at runtime. This way, it becomes possible to mock final classes and methods what is important in order to support new JVM languages such as Kotlin where, by default, all methods are final. With this new mock maker, Byte Buddy needs to rewrite large fractions of a class.

  5. We always value feedback from our users, so can you tell us what you’d like us to improve or are there features that we should add support for?

    Hibernate has been my first choice for an O/R Mapper in many years, and I am very happy how well it works. One critique I had was the lack of documentation.

    People are often abusing the library’s capabilities or run into performance issues because they do not understand what the library is doing and what its intended use case is. And to be fair, this is not always easy to figure out.

    I feel like the state of documentation has improved a lot in the last time, and I very much welcome this effort.

Thank you, Rafael, for taking your time. It is a great honor to have you here. To reach Rafael, you can follow him on Twitter.

Meet Julien Dubois and JHipster

Posted by    |       |    Tagged as Discussions Hibernate ORM

In this post, I’d like you to meet Julien Dubois, the Team Leader of JHipster.

Julien Dubois, align=
  1. Hi, Julien. Would you like to introduce yourself and tell us a little bit about your developer experience?

    Hi Vlad, I’m Julien Dubois, and I’ve been a software developer for the last 20 years, mainly focusing on Java and Web development.

    I’m involved in the Open Source and Java communities: I’ve written a book on the Spring Framework, contributed to many different OSS projects, and talked at a lot of conferences.

    Currently, I’m Chief Innovation Officer at Ippon Technologies, a Java consultancy with offices in France, the US and Australia. I’m also the CTO of DataMC, a VC-backed startup specialized in Big Data solutions.

  2. You are the team leader of JHipster. Can you tell us about the goals of this open-source framework?

    It’s all about having a great developer experience: we integrate a lot of cool technologies like Spring Boot, Hibernate, AngularJS and Docker, and automate all the tasks you would usually do manually. In the end, you win a lot of time, and your project has a much higher quality.

    We, of course, have great Hibernate support, and even have an online IDE to help generate complex data models.

    Another great thing is that we have a huge community, with lots of people and companies contributing. This ensures we have tons of ideas, patches and best practices, which is something nobody could ever achieve alone.

  3. JHipster uses Hibernate ORM for data. Why did you choose Hibernate over other JPA providers?

    At Ippon Technologies, I have seen many projects, probably more than 50 in the last 5 years. I’d say 80% of people use JPA and Hibernate together, and the rest have either some custom JDBC code, a proprietary framework (like Jalo, which comes with Hybris), or an Open Source alternative (like MyBatis).

    But I haven’t seen anyone using another JPA provider for a very long time. A couple of years ago, I saw one project which wanted to test Batoo JPA, but that implementation is not maintained anymore.

    So, for JHipster, we use Hibernate because it’s the most widely-used, better-maintained implementation, and also because I trust Red Hat to be a great sponsor for the project.

  4. We always value feedback from our users, so can you tell us what you’d like us to improve or are there features that we should add support for?

    My main issue with Hibernate on JHipster is the startup time. On my laptop, I need 10 seconds to start a Hibernate application, compared to 7 seconds for a MongoDB application. All this time isn’t caused by Hibernate itself, as there are also the connection pool and the 2nd-level cache to start, but the whole stack is a bit heavy when coding.

    In production mode, we also need something that starts up really fast, and that’s definitely the biggest issue for me. For instance, when using microservices with Docker, or when using cloud providers like Heroku or Cloud Foundry, this really goes against Disposability (the number 9 of the 12 factors).

    So I’m wondering if we could have an option where Hibernate starts quickly without doing any check, and then fails fast on any error, like an incorrectly-written query.

Thank you, Julien, for taking your time. It is a great honor to have you here. To reach Julien, you can follow him on Twitter.

back to top