6 Hibernate Best Practices for Readable and Maintainable Code
|

6 Hibernate Best Practices for Readable and Maintainable Code

Implementing a readable and maintainable persistence layer with Hibernate isn’t as easy as it might seem. It often starts with just a few annotations on some Java classes and a small number of Strings containing things like JPQL or native query statements and references to attributes, queries and bind parameter names. As the project grows, you implement more entity…

Can you use Hibernate/EclipseLink/JPA for your microservice?
|

Can you use Hibernate/EclipseLink/JPA for your microservice?

Everyone is building microservices. For the last 1.5 years, it was the dominant architectural style for all new software projects. And while a microservice architecture should make the implementation of each service easier, it also introduces new challenges. That’s especially the case for the persistence layer. So, it’s no surprise that I had lots of…

Access Strategies in JPA and Hibernate – Which is better, field or property access?
|

Access Strategies in JPA and Hibernate – Which is better, field or property access?

The access strategy defines how your JPA implementation, e.g., Hibernate or EclipseLink, access your entity attributes. You can choose between field-based access and property-based access: If you use field-based access, your JPA implementation uses reflection to read or write your entity attributes directly. It also expects that you place your mapping annotations on your entity attributes….

Hibernate Tips: How To Apply DISTINCT to Your JPQL But Not Your SQL Query

Hibernate Tips: How To Apply DISTINCT to Your JPQL But Not Your SQL Query

Hibernate Tips is a series of posts in which I describe a quick and easy solution for common Hibernate questions. If you have a question for a future Hibernate Tip, please post a comment below. Question: I’m using a query with a JOIN FETCH clause to load parent entities with all their child entities. The JPQL…