Introduction In this article, we are going to see how we can cascade the DELETE operation for unidirectional associations with Spring Data JPA and Hibernate events. Using Hibernate events to achieve this goal is an alternative to the bulk DELETE statement strategy, as it allows us to cascade the delete operation from a parent entity to its children when we cannot use the CascadeType mechanism.
Introduction In this article, we are going to see how to cascade DELETE the unidirectional associations with Spring Data JPA when we cannot rely on the CascadeType mechanism that propagates state transitions from parent to child entities.
Introduction In this article, we are going to see what is the best way to use Spring Data JPA Stream query methods. When having to fetch a larger result set, the advantage of using a Java Stream is that the query result set could be fetched progressively instead of getting all the data at once.
Introduction In this article, we are going to see how the Spring Data JPA Query By Example (QBE) feature works, when you should use it, and what limitations it has. While Spring Data JPA already provides a wide range of options to query data: query methods or the @Query annotation Spring Data JPA Specification custom Repository query methods The Spring Data Query By Example feature is meant to offer a way to decouple the data filtering logic from the query processing engine so that you can allow the data access layer clients… Read More
Introduction In this article, we are going to see what is the best way to use the Spring Data JPA Specification when combining multiple predicates with the result set ordering logic. While you can also use query methods or the @Query annotation to define your Spring Data queries, the Spring Data JPA Specification allows you to compose dynamically various filtering criteria, which may be very convenient when you’d, otherwise, end up with lots of query method permutations.
Introduction In this article, we are going to see how we can use the JOIN FETCH clause when fetching a child collection eagerly while also limiting the number of parent records using pagination in a Spring Data JPA application. I decided to write this article because the most common solution used in many projects turns out to be extremely inefficient.
Introduction In this article, we are going to see how Spring Data query methods are built, when you should use them, and especially when you should avoid them. I decided to write this article after answering this StackOverflow question, which depicts an 87-character-long Spring Data query method. TL;DR, Don’t write query methods that cannot even fit on the screen.
Introduction In this article, we are going to see how we can achieve fault tolerance in your Spring Data application with the help of YugabyteDB. As previously explained, YugabyteDB is an open-source distributed SQL database that combines the benefits of traditional relational databases with the advantages of globally-distributed auto-sharded database systems.
Introduction In this article, I’m going to explain how you can use the BaseJpaRepository from the Hypersistence Utils OSS project as an alternative to the default Spring Data JpaRepository. The reason why I’m not using the default JpaRepository on any of my Spring projects is that it provides some terrible defaults that can be very easily misused, like: The findAll Anti-Pattern The JPA save Anti-Pattern So, there are two ways you can fix the problems induced by the default JpaRepository: You can use the HibernateRepository to deprecate the questionable methods that you… Read More
Introduction In this article, we are going to see how the Spring Data JPA findById method can become an Anti-Pattern when using it to reference parent entity associations.