In this post, I’d like you to meet Christian Beikov, who is one of the most active Hibernate contributors.
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.
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.
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.
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 :)
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.
Rafael has done a great job migrating Hibernate from Javassist to Byte Buddy, for which we are very grateful.
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.
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.
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.
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.
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.
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.
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.
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.
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.
In this post, I’d like you to meet Thorben Janssen, a long-time Hibernate user and blogger.
Hi, Thorben. Would you like to introduce yourself and tell us a little bit about your developer experience?
Hi and thanks for having me.
My name is Thorben Janssen. I’m 36, married and father of a small son. I’m also a trainer, blogger, and developer with a strong focus on JPA and Hibernate and a CDI 2.0 expert group member.
My career started more than 15 years ago with an internship and the development of various small PHP applications for mobile phone operators. It didn’t take long until I joined the rest of the development team and started to work with EJB 2 and JBoss application servers. In the beginning, that was a painful experience. EJB 2 was hard to learn and created a dislike for XML files that still exists.
But it also got me into Java EE and the implementation and design of large systems. And that’s what I’ve been doing ever since. During these years, I also managed small to mid-sized development teams and acted as an architect. But I always was and still am a Java EE developer at heart who’s spending as much time as possible in the IDE. I think that the interest for new things and the tools he/she is using is one of the key characteristics of a good developer. I always read about upcoming specification changes or new, proprietary features in their implementations and try them in small side-projects. At some point, I started to share my knowledge with my co-workers, and it led me to my new passion: teaching others by writing and speaking about JPA and Hibernate.
Your site, Thoughts on Java, features a great deal of JPA and Hibernate tutorials. Why did you decide to write about this topic?
That happened more or less by accident. As I said earlier, I’ve always worked on backend applications, and the persistence tier is an important part of these.
I’ve always been interested in ways to make the database access easier and more efficient. Simple read and write operations should be easy to implement. Our customers don’t pay us to read some records from the database. They expect us to solve complex business requirements.
I spend a huge part of my career learning about and even more time implementing efficient database access with Hibernate. When I started my blog, I was looking into the changes introduced in JPA 2.1. I found a bunch of useful, new features, like
@NamedEntityGraph, stored procedure calls, and
AttributeConverter. I wanted to document them so that I could easily use them in future projects.
As soon as I shared links to my posts on social media, I was surprised how many developers shared my interest in these things. Hibernate and JPA were my main interest and became the main topics of my blog. That was 3 years ago, and the blog has now grown to more than 100.000 page views per month, a free member library with ebooks and cheat sheets and a small YouTube channel.
It also provided me the opportunity to speak at conferences and offer classroom and online trainings.
Currently, you decided to run your own training business. Could you please tell us more about it and how it’s been going so far?
At some point, this was the next logical step. I started with a small side-business and gave a few classroom workshops. At the beginning of this year, I did my first Hibernate Performance Tuning Online Training. There was a lot of interest and it quickly grew to a point where I wasn’t able to work my day job, write the blog and offer training. My wife and I then decided that I should quit my day job and concentrate on my own business.
So far, that was a great decision. The last 2 months were hard but I also had a lot of fun. The additional time allowed me to finally launch the free member library (a project I wanted to work on since the end of 2015) and a new Hibernate Training.
In my new Advanced Hibernate Online Training, I explain a lot of advanced JPA and Hibernate features that you can use to create dynamic, type-safe queries, support custom data types, implement multi-tenant applications and manage concurrency. I’m also offering the Hibernate Performance Tuning Online Training in which I show you how to find and fix performance issues. It’s the online version of my 2-day classroom training, and we dive deep into various JPA and Hibernate features that allow you to fulfill high-performance requirements easily. You can have a look at some lectures in this free video series.
I’m offering both trainings 2-3 times a year with a self-study and a group coaching option. The self-study option provides you lifelong access to the training videos so that you can study at your leisure. The group coaching offers several benefits on top of that, like access to the community forum to discuss your questions and additional exercises. This makes it similar to a classroom training and more effective than the typical online course.
The registration for both trainings is currently open, and you can join until November 11th.
What are your plans for the future? Will you continue to write about Hibernate or do you also want to write about other topics?
There are a lot of other interesting Java EE-related topics. But for now, I will focus on JPA and Hibernate. I still have a long list of interesting features I want to write about and I just started to publish Hibernate-related videos on my youtube channel.
The next big projects will be a 3rd Hibernate training and a book. The 2 existing trainings are for experienced Hibernate users who want to deepen their knowledge and learn to use it more efficiently. The 3rd training will be for Hibernate beginners who want to learn how to map a database table to an entity and how to perform simple queries. I want to work on that in the first half of 2017.
We always value feedback from our users, so can you tell us what you’d like us to improve the Hibernate projects (ORM, Search , Validator, OGM) or are there features that we should add support for?
I like the new Java 8 support you introduced with Hibernate 5. From my point of view, the support of the Date and Time API is a must for modern persistence frameworks and features like repeatable annotations and the support for Streams and Optional make it much more comfortable to use.
The 2 features I’m missing right now are better support for subselects and discriminator-based multi-tenancy. JPA and Hibernate provide only basic support for subselects. It would be great, if you could use them in the SELECT and FROM clause and not only in the WHERE clause. The discriminator-based multi-tenancy support seems to be already on your list, and I’m looking forward to it.
Thank you, Thorben, for taking your time. It is a great honor to have you here. To reach Thorben, you can follow him on Twitter.
Hi, Michael. Would you like to introduce yourself and tell us a little bit about your developer experience?
My name is Michael Simons, @rotnroll666 on Twitter.
I am a 37 year old developer living in Aachen, Germany. As such, I qualify at least age wise as a senior developer. I’ve been in the software industry for nearly 15 years now. I do have a technical apprenticeship and half finished degree in applied Mathematics. I never finished those studies as I landed in the company I still work with, ENERKO INFORMATIK.
Apart from being a husband and a father of two, I run our local JUG, the Euregio JUG.
I’m also a member of the NetBeans Dream Team.
We, at ENERKO INFORMATIK, create software in the energy and utility markets and work both in the technical and geographical parts as well as sales.
I did really database-centric software for at least 4 years and, I am still fluent in SQL and also PL/SQL. We once did XML processing inside Oracle databases, which works surprisingly well. After the slow death of Oracle Forms Client / Server, we migrated our desktop applications from 2004 onwards to Java Swing.
Around that time I played around with Hibernate for the first time. It seemed like the golden bullet back then to get table rows into objects. It wasn’t. But that I learned much later. As Gavin King said: „Just because you’re using Hibernate, doesn’t mean you have to use it for everything.“
Apart from „boring“ business application, I’ve been not only blogging for a long time but ran several online communities, one of them still alive. Daily Fratze is a daily photo project started in 2005 as a PHP application. Then, in 2006 became a Ruby on Rails site and by 2010, I started migrating it to a Spring and Hibernate backend.
Looking back at that code I notice how much I didn’t know about the purpose and intention of JPA / Hibernate. As it is true for a lot of stuff, you have to know your tools and the stuff they are designed for. Not all relations are meant to be materialized in objects, not all queries can be generated. And knowledge about when a
Sessionis flushed and when not is essential. It’s not enough to know SQL to fully utilize Hibernate, but it’s also not enough to know Hibernate for abstracting persistence away. I changed the flaws in the site code, but you as the reader of this interview must not learn it the hard way, I really recommend Vlad Mihalcea's book High-Performance Java Persistence.
My biking project and the site and API of the Euregio JUG are my latest public projects that represent the stuff learned with the experience above. I use those projects as reference projects for my work.
You’ve designed the Java User Group Euregio Maas-Rhine site. Can you tell us what frameworks have you used?
Spring Boot as the application container and glue for
Spring Framework and MVC
JPA and its implementation Hibernate
Spring Data JPA
The frontend is done pretty old school by server side rendered templates using Thymeleaf.
As a rule of the thumb I’d choose the following stack when using any kind of SQL data store:
JPA / Hibernate together with Spring Data JPA as long as I can express my domain model as entities and tables
JPQL queries if necessary with the benefit that they are checked at application start
No native queries hidden away in some annotations
If I have to do native queries, I’ll choose Springs JDBC template or since 2015 jOOQ if applicable.
My rule for switching to native queries is when I do have projections or „hard“ analytics that would take an awful lot of Java Code instead of a few lines SQL.
Why did you choose Hibernate ORM and Search over other frameworks and did it match your expectations?
From my background, the data model has always been essential. I worked with awesome models and not so great ones. If you can map your domain to a data model, having a working domain driven design, Hibernate helps you a lot to materialize it back into Java.
We want to publish articles (posts) and events on the site. People should be able to register for those events, one time each. This fits perfectly into a simple and well understandable domain model that maps perfectly to objects and entities.
Why bother writing those plain SQL statements for selecting and updating stuff myself?
I chose the combination of Hibernate and Spring Data JPA for a reason: The domain I map in Hibernate facilitates all the „magic“ Spring Data JPA does: Generating queries, conditions and such: I hardly have to write anything myself.
If you chose JPA / Hibernate ORM in your project, I really recommend adding Spring Data JPA to the mix. Even if it’s a Java EE project. Spring Data JPA is a bit harder to configure there but provides the user with a lot of helpful stuff.
Using Hibernate Search integration was an experiment. I’m using it for a long time now on my daily photo project. With little effort, my entities provide access to a Lucene based index and I don’t have to fight with SOLR.
The EuregJUG site has no local storage in contrast to my daily photo project. So, I had to test drive the upcoming Elastic Search integration in 5.6.0, which works with the same set of annotations, the same entities but not against a local index but against a remote Elastic search index. You can see it in those commits described here and use it here.
It really isn’t much stuff added, it fits into the repository / DDD approach and matches my expectations.
Regarding Spring Boot, I’ve been doing Spring now for more than 7 years and Boot since early 2014. It has an awesome community and actually never disappointed me.
As a Hibernate user the most common problems I had during the time which I didn’t know exactly what I was doing: Having problems mapping my tables, slow queries and such. Also throwing Hibernate at problems that would have been a better fit for plain SQL caused problems. In both cases, those problems could be solved on my end.
The experience in Hibernates bug tracker is improving a lot lately and I would appreciate an even better integration with Spring Data JPA.
To close this, I have to say that I really like the stack mentioned above. We have reached a quality of component where you can really work well from a Domain Driven Design perspective, switch to SQL if needed and still having a clean architecture with clean, testable code. Problems that have been around 10 years ago most often gone.
It’s really not hard to get an application up and running, including unit and integration tests. If you leave aside the hypes, you can concentrate on both actual problems and on enabling people to learn and do their jobs.
I really like the fact that Hibernate Spatial find its way into ORM itself. If you have correctly mapped entities and you need to query them via spatial regions, that stuff is really helpful and works quite well. I’d appreciate more information there.
Thank you, Michael, for taking your time. It is a great honor to have you here. To reach Michael, you can follow him on Twitter.
In this post, I’d like you to meet Petar Tahchiev, a long-time Hibernate user, and open-source contributor.
I had the chance of meeting Petar in Cluj-Napoca. Here you can see Petar opening a Hibernate Pull Request that he recently sent us for review.
Hi, Petar. Would you like to introduce yourself and tell us a little bit about your developer experience?
Hi Vlad, thanks for having me. My name is Petar Tahchiev, and I am a Java developer from Bulgaria. My experience with open-source dates back to 2006 when I joined the Apache Software Foundation as Jakarta Cactus lead developer. I also became an Apache Maven committer later that year, and I also co-authored the second edition of JUnit in Action.
While I kept the open-source as a hobby, on a professional level I spent the last eight years of my life implementing e-commerce projects for some of the largest corporations in the world using proprietary software. Then, I finally decided that I can build a way better e-commerce platform using the latest and greatest of the open-source software and thus combine my hobby with my job. And this is actually how Nemesis Software was born.
You are developing the Nemesis platform. Can you tell us what’s the main goal of such a platform?
Well, Nemesis is an e-commerce platform, although e-commerce is just one of many other modules. It’s basically a Spring Boot application with a modular architecture where customers can select the different modules they want to use so they can specify what kind of project they are going to build. Each module has a Spring Boot auto-configuration and consists of a set of JPA entities, a set of services that operate with those entities and different configuration properties to allow you to customize the given module.
The modules of the nemesis platform allow you to customize completely the purpose of the platform. We have modules for e-commerce, B2B commerce, CMS, analytics, financial services, you name it. This way you can pick the right modules for you and initialize the database with the right columns/tables, etc.
For initializing the database, we use Hibernate’s hbm2ddl schema export tool which produces SQL scripts and then we also use FlywayDB to execute the SQL scripts and version the database.
Our platform also comes with a Maven archetype so our customers can generate a project and have it up-and-running in less than 5 minutes, and on top of all that the generated project is designed to be a 12-factor app so you can easily deploy it to any cloud provider out there.
Nemesis is using Hibernate for data persistence. Why did you choose Hibernate and did it match your expectations?
Yes indeed, although most of our clients are huge corporations and sometimes they are biased on the products they want to use So, we want it to be easy for us to switch the JPA provider if such a need ever occurs. That is the reason why we want to stay as close as possible to any JSR standard.
Nevertheless, out-of-the-box our platform comes with Hibernate as a JPA provider, and this is what we recommend to our clients. The reasons behind this are several. While we have researched most of the JPA providers, we consider Hibernate to be the most mature project with the largest community out there. That’s something really important for us - we want to provide our clients with the fastest time-to-market development, and to be able to do that, we need to use a technology stack that is closest to most of the developers.
It turned out that Hibernate is one of the most popular Java projects among regular developers. Another reason we chose Hibernate is that it has a very carefully planned release schedule so we know exactly when a new feature or a fix will be shipped. So far, it has proven to be an excellent choice.
Your platform competes with SAP. Do you think that using open-source frameworks like Spring and Hibernate is a competitive advantage for you?
I can spend days if not weeks talking about the importance of using open-source tools like Spring and Hibernate compared to proprietary software like SAP, or IBM.
On the one hand, you get access to a large pool of resources - developers all over the world they know Spring, Hibernate, Tomcat, Drools, etc. So, it’s a lot easier for them to pick up the software and just be productive.
Having to choose from a large pool of resources means cheaper implementation costs for our customers compared to niche products.
When using open-source software our customers also get to use first-class documentation (great work on the Hibernate documentation by the way). And, if by any chance they can’t find anything in the documentation, they can always download the source code and debug to see what’s happening, or even patch it and contribute back to the community.
And that’s just the tip of the iceberg - the biggest benefit of all is that our clients actually get one more level of support. If our customer’s development team has troubles with the open-source tools, they can always google the error they get, and, only when they don’t find what they are looking for, they come to our customer support.
This actually saves us a lot of time because we know when someone comes to us, it is most likely because of an issue in our own software.
Thank you, Petar, for taking your time. It is a great honor to have you here. To reach Petar, you can follow him on Twitter.
Hi, Mark. Would you like to introduce yourself and tell us what you are currently working on?
I am Mark Paluch, and I am working for Pivotal Software as Spring Data Engineer. I am a member of the JSR 365 EG (CDI 2.0), project lead of the lettuce Redis driver, and I run a couple of other open source projects. I enjoy tinkering on Internet of Things projects in my spare time. Before I joined Pivotal, I worked since the early 2000’s as a freelancer in a variety of projects using Java SE/EE and web technologies. My focus lies now on Spring Data with Redis, Cassandra, and MongoDB in particular.
You have contributed a lot to the Hibernate OGM Redis module. Can you please tell us a little bit about Redis?
I was not the first one bringing up the idea of Redis support in Hibernate OGM. In fact, Seiya Kawashima did a pretty decent job with his pull-request but at some point, Hibernate OGM development and the PR diverged. I came across the pull request and picked it up from there.
Redis is an in-memory data structure store, used as database, cache and message broker. It originated from a key-value store but evolved by supporting various data structures like lists, sets, hashes and much more. Redis is blazing-fast although it runs mostly single-threaded. Its performance originates in a concise implementation and that all operations are performed in-memory. This does not mean that Redis has no persistence. Redis is configured by default to store data on disk and disk I/O is asynchronous. Redis facilitates through its versatile nature an enormous number of use-cases such as Caching, queues, remote locking, just storing data and much more. An important fact to me is always that I’d never use Redis for data I cannot recover as wiping data from Redis is just too easy but using it as semi-persistent a store is the perfect use.
You are also the author of the Lettuce open source project. How does it compare to Hibernate OGM?
Hibernate OGM and lettuce are projects with different aims. Lettuce is a driver/Java-binding for Redis. It gives Java developers access to the Redis API using synchronous, asynchronous and reactive API bindings. You can invoke the Redis API with lettuce directly and get the most out of Redis if you need it. Any JDBC driver is situated on a similar abstraction level as lettuce except for some specific features. lettuce does not require connection-pooling and dealing with broken connections as it allows users to benefit from auto-reconnection and thread-safe connections. Hibernate OGM Redis uses this infrastructure and provides its data mapping features on top of lettuce.
What benefit do you think Hibernate OGM offers to application developers compared to using the NoSQL API directly?
Each NoSQL data store has its own, very specific API. Native APIs require developers not only get familiar with the data store traits but also with its API. Redis API comes with over 150 commands that translate to 650+ commands with sub-command permutations.
Every Redis command is very specific and behaves on its own. The Redis command documentation provides detailed insight to commands, but users are required to spend a fair amount of their time to get along with the native API.
Hibernate OGM applies elements from the JPA spec to NoSQL data stores and comes up with an API that Java EE/JPA developers are familiar. Hibernate OGM lowers barriers to entry. Hibernate OGM comes with a purpose of mapping data into a NoSQL data store. Mapping simple JPA entities to the underlying data store works fine but sometimes, like associations or transactions, do not map well to MongoDB and Redis. Users of Hibernate OGM need to be aware of the underlying persistence technology to get familiar with its concepts and strengths as well with their limitations.
I also see a great advantage of the uniform configuration mechanism of Hibernate OGM. Every individual datastore driver comes up with its individual configuration method. Hibernate OGM unifies the styles into a common approach. One item on my wish list for Hibernate OGM is JDNI/WildFly configuration support to achieve similar flexibility as it is possible with JDBC data sources.
Do you plan on supporting Hibernate OGM in Spring Data as well?
Hibernate OGM and Spring Data follow both the idea of supporting NoSQL data stores. Hibernate OGM employs several features from NoSQL data stores to enhance its data mapping centering around JPA. JPA is an inherently relational API, which talks about concepts that are not necessarily transferable to the NoSQL world. Spring Data comes with modules for various popular data stores with a different approach to providing a consistent programming model for the supported stores but not try to force everything into a single abstracting API. Spring Data Modules provide multiple levels of abstraction on top of the NoSQL data store APIs. Core concepts of NoSQL data stores are exposed through an API that commonly looks and feels like Spring endpoints. Hibernate OGM can already be used together with Spring Data JPA. A good use-case is the Spring Data Repositories abstraction which provides a uniform interface to access data from various data stores that do not require users to write a query language and leverages store-specific features.
Thank you, Mark, for taking your time. It is a great honor to have you here. To reach Mark, you can follow him on Twitter.
In this post, I’d like you to meet Sergey Chernolyas who is one of our Hibernate OGM project contributors.
Hi, Sergey. You are one of the people who contributed to the Hibernate OGM project. Can you please introduce yourself?
Hi, Vlad! My name is Sergey Chernolyas. I am from Russia, and I am 38 years old. I have been working with Java technologies since 2000. During my career, I got four certificates on Java technologies from Oracle and got involved in many development and integration projects.
Can you tell us what project are you currently working on and if it uses Hibernate OGM?
Now, I am working on a new module for Hibernate OGM, which aims to integrate the OrientDB NoSQL database. With this module, OGM will support a total of 7 NoSQL databases. Although at my current job, my work is not related to NoSQL solutions or Hibernate OGM, I am interested in this topic, and that’s why I pushed myself to learn Hibernate OGM and exploring NoSQL databases.
Can you tell us a little about OrientDB?
OrientDB is a graph-oriented and document-oriented database, and it is built using Java technologies. Briefly, the main advantages of using OrientDB are:
It can operate in several modes: as an in-memory database, or through a network connection, or it can be store data in a local file.
It offers join-less entity associations.
It has good performance and is Big Data-oriented.
For more details about OrientDB, you can visit the official documentation. Recently, the OrientDB team released the 2.2 GA version, so it’s worth giving it a try.
What is the main benefit of using Hibernate OGM for accessing OrientDB over using their native API?
The main benefit of using Hibernate OGM over the native API is the standard way for application development. Also, Hibernate OGM hides many low-level operations for creating and managing database connections, or for executing queries.
While implementing the first version of the OrientDB Hibernate OGM module, I was faced with some OrientDB issues that prevented me integrate all features that ought to be supported by any Hibernate OGM module. Luckily, the OrientDB team was helpful and supportive, and I hope that by the time I finish this integration, the OrientDB team had already fixed my previously reported issues.
Thank you, Sergey for taking your time, and keep up the good work.
In this post, I’d like you to meet Martin, who, in spite of his young age, has been very active in the Hibernate Search project development, implementing some interesting extensions or helping with pull request reviewing.
Because I’d love to see more university students getting involved with open source software, I took this opportunity and interviewed Martin about this experience.
Hi, Martin. You are one of the youngest contributors we’ve ever had. Can you please introduce yourself?
Hi, Vlad. I am a 22-year-old Master’s Degree student at University of Bayreuth, Germany and have been interested in Hibernate Search and Fulltext Search (Lucene, Solr) for quite some time now. I am also a firm believer of Open Source and have actually always wanted to become a contributor of a tool (or software) many other developers use in their projects. Knowing that a piece of code you wrote is running in other systems is quite the rewarding feeling.
I understand that you took part in the Google Summer of Code event. Can you tell us a little bit about this program?
Yes, I took part in last year Google Summer of Code program and was mentored by Sanne Grinovero while working on adapting Hibernate Search to work with any JPA provider. It gave me the opportunity to dive more deeply into the codebase as it allowed me to concentrate on nothing but my project work-wise. In general Google Summer of Code is one of the best learning experiences any student that wants to get into Open Source can have.
Contributing to an open-source project is a great learning experience. Has this activity helped you improve your skills?
Definitely. While building new features or tracking down bugs, you encounter loads of different pieces of code you have to work through. With that comes learning new technologies and APIs. Also, the general process of submitting JIRA issues, discussing them and implementing the solutions is something you can learn while working on an open source project. Trying out the process yourself is invaluable and cannot be compared to just learning them on paper. This is also something I always tell to new coders: Try it out or you will not get it 100%.
Do you think the entry barrier is high for starting contributing to an open source project? How should we encourage students to getting involved with open source?
In the case of the Hibernate team, I can only say that it was quite easy to get into contact with the other developers. I just got onto IRC and asked questions about problems I had. They helped me with every question I had, so I stuck around. Then, I started reporting issues or making feature requests and was immediately incorporated into discussions. So no, the barrier is not high (at least for me in the case of the Hibernate team).
I think open source needs to be encouraged more at a university level. I think many students don’t realize what they are missing. Yes, open standards are encouraged and teaching uses open APIs all over the place, but universities tend to keep much of the work that is suitable for open source behind closed doors (btw: I don’t think that closed source is always a bad thing, but it sometimes is in the way of innovation).
What are your plans for the future?
Firstly, I want to finish my Masters degree at University. I haven’t fully decided yet, whether I want to stay at University or not. Time will tell, I guess. Secondly, I want to keep contributing to Hibernate Search and finish merging the features of last years Google Summer of Code into the core code base.
Thank you, Martin, and keep up the good work.