My JPA 2.0 Wish List

(Article originally published in June 2008)

Until now we have enjoyed easy persistence using JPA 1.0. It's true that JPA 1.0 has some limitations, but now our friends from JSR-317 are working hard to give us a better standard of persistence for Java.

10 More Common Mistakes Java Developers Make when Writing SQL

i was positively surprised to see how popular my recent listing about   10 common mistakes java developers make when writing sql   was, both  on my own blog  and  on my syndication partner dzone  . the popularity shows a couple of things:

anyway, the common mistakes i listed previously are far from complete, so i will treat you to a sequel of 10 subtly less common, yet equally interesting mistakes java developers make when writing sql.

Using Db4o in an Android Application

Db4o is an object database, i.e., forget about the mapping of tables in a relational database model. If you're a developer, that translates into savings in time invested in your application and volume of code. Db4o's great potential is that you can reuse your [plain, non-mapped] objects by saving and retrieving them as many times as you want. You can persist complex objects or design patterns with nested collections or other complex objects at any level of complexity in your hierarchy. You're not limited to flat objects with primitive types to get reasonable performance.

With db4o you can also benefit from native queries which bring you closer to the language and combine optimized execution with simplicity even for complex queries. Db4o is open source and can be downloaded here.

A (Definitive?) Guide on LazyInitializationException

Posts that have been written about Hibernate's LazyInitializationException could probably fill whole books. Yet, I believe each of them focuses on a particular aspect of it: some on a specific solution, some on how to solve it with Spring Boot, etc. I'd like this post to be the definitive guide on the subject, even though I'm pretty sure it won't. At least, I'll be able to point others to it.

The Root Cause

Whether you love or hate ORM frameworks in general, they are nonetheless pretty common in the Java ecosystem. JPA is the ORM standard and part of the Jakarta EE specifications. Hibernate is its most widespread implementation: for example, it's the default in Spring Boot.

Redis Is Not Just a Cache

Do You Always Need a Classic Database?

For some time now the huge amount of data that needs to be processed forces any app to have a caching strategy in front of the databases. The databases, even with huge underline optimizations, can’t always provide enough speed and availability. The main reason is that the farther is the data, the harder it is to access it. Another reason is that usually, a database persists data on disk and not on RAM. They do have embedded cache on RAM for increasing the optimizations but, even so, having a dedicated separated cache is a well-used strategy.

The usual solution to solve the performance issues when accessing a database is caching. Caching isn’t new. Caching actually means to keep a smaller amount of data that you frequently access closer to you. We have caches on processors, databases have embedded caches also and you can even code your own cache in your app. 

What is Persistent ETL and Why Does it Matter?

If you’ve made it to this blog you’ve probably heard the term “persistent” thrown around with ETL, and are curious about what they really mean together. Extract, Transform, Load (ETL) is the generic concept of taking data from one or more systems and placing it in another system, often in a different format. Persistence is just a fancy word for storing data. Simply put, persistent ETL is adding a storage mechanism to an ETL process. That pretty much covers the what, but the why is much more interesting… 

ETL processes have been around forever. They are a necessity for organizations that want to view data across multiple systems. This is all well and good, but what happens if that ETL process gets out of sync? What happens when the ETL process crashes? What about when one of the end systems updates? These are all very real possibilities when working with data storage and retrieval systems. Adding persistence to these processes can help ease or remove many of these concerns. 

Advanced Process Integration Tips -Configuring External Persistence

Using advanced process integration techniques becomes essential as you evolve your developer skills while integrating more and more of your business workflows. One of the more common questions is how to persist custom data and configure external persistence?

When working with processes, it is expected to work with persistent process data scenarios. Considering this situation, it is common for users to use a different database to store process data, apart from the database where the domain information is stored.

Why Set Is Better Than List in @ManyToMany

In this article, we'll highlight the performance penalties involves by using List or Set in @ManyToMany relationships. We use Spring Data JPA with the default persistence provider, therefore with Hibernate JPA.

First of all, keep in mind that Hibernate deals with @ManyToMany relationships as two unidirectional @OneToMany associations. The owner-side and the child-side (the junction table) represents one unidirectional @OneToMany association. On the other hand, the non-owner-side and the child-side (the junction table) represent another unidirectional @OneToMany association. Each association relies on a foreign key stored in the junction table.

High-Performance Persistence With MicroStream (Part Three)

Learn how to keep your apps performing!

For some time, there has been a new competitor in the field of persistence and serialization. We are talking about Project MicroStream. What is it exactly? MicroStream claims to be a high-performance and, most importantly, developer-friendly solution for the challenges of serialization and persistence.

High-Performance Persistence With MicroStream (Part Two)

Keep pushing for the best performance possible!


For some time, there has been a new competitor in the field of persistence and serialization. We are talking about Project MicroStream. What is it exactly? MicroStream claims to be a high-performance and, most importantly, developer-friendly solution for the challenges of serialization and persistence. How easy, fast and comfortable that is, we will look at in detail in a multi-part series.

JPA With Eclipse and MySQL Using Java Configuration

In this article, we will discuss the Java persistence API configuration with EclipseLink and MySQL.

The Java Persistence API is a standard specification for ORM (Object Relational Mapping) implementations. Also, it shows how to define a PLAIN OLD JAVA OBJECT (POJO) as an entity and how to manage entities with relations.

Best Performance Practices for Hibernate 5 and Spring Boot 2 (Part 1)

Item 1: Attribute Lazy Loading Via Bytecode Enhancement

By default, the attributes of an entity are loaded eager (all at once). Are you sure that you want that?

Description: If not, then is important to know that attributes can be loaded lazily, as well via Hibernate bytecode instrumentation (another approach is via subentities). This is useful for column types that store large amounts of data: CLOB, BLOB, VARBINARY, etc.

Deadlock in Databases

From databases perspective, a deadlock is a phenomenon that occurs when two transactions are blocking each other.

In the figure above, we have a classic deadlock situation. Transaction A (old man transaction) holds a lock to resource A (Dogs), but it doesn't release it until it will acquire a lock to resource B (Cats) that is currently locked by transaction B (young man transaction). In the same time, transaction B (young man transaction) holds a lock to resource B (Cats), but it doesn't release it until it will acquire a lock to resource A (Dogs) that is currently locked by transaction A (old man transaction).

Akka Persistence: Making Actor Stateful

Akka is a toolkit for designing scalable, resilient systems that span processor cores and networks. Akka allows you to focus on meeting business needs instead of writing low-level code to provide reliable behavior, fault tolerance, and high performance.

Akka actor can have state but it’s lost when the actor is shutdown or crashed. Fortunately, we can persist actor state using Akka Persistence, which is one of Akka extensions.