The post Date and Time Mappings with Hibernate and JPA appeared first on Thorben Janssen. Databases support various data types to store date and time information. The most commonly used ones are: You can map all of them with JPA and Hibernate. But you need to decide to which Java … | Continue reading
The post AI Glossary for Java Developers appeared first on Thorben Janssen. Most Java developers encounter problems when learning how to integrate AI into their applications using SpringAI, Langchain4J, or some other library. AI introduces many new terms, acronyms, and techniques … | Continue reading
The post How to define a repository with Jakarta Data and Hibernate appeared first on Thorben Janssen. Repositories are a commonly used pattern for persistence layers. They abstract from the underlying data store or persistence framework and hide the technical details from your b … | Continue reading
The post Getting Started with Jakarta Data and Hibernate appeared first on Thorben Janssen. Jakarta Data standardizes stateless repositories based on Jakarta Persistence and Jakarta NoSQL so that you can concentrate on your business code instead of handling the technical details … | Continue reading
The post Should your tests manage transactions? appeared first on Thorben Janssen. During my Spring Data JPA workshops and talks, I often get asked if a test case should handle transactions, or not. And if it handles the transaction if it should commit it or roll it back. And as … | Continue reading
The post Databases and AI with Neo4J as an example with Michael Simons appeared first on Thorben Janssen. When integrating AI into your application, you will most likely want to use a concept called RAG. This acronym stands for Retrieval Augmented Generation and is an absolute ga … | Continue reading
The post Implement your primary key as a Record using an IdClass appeared first on Thorben Janssen. There are various reasons to implement your own primary key representation. Your primary key may consist of multiple attributes. Or you’re following domain-driven design principles … | Continue reading
The post Persist LocalDateTime, ZonedDateTime & Co with Hibernate appeared first on Thorben Janssen. The Date and Time API, introduced in Java 8, finally replaced the old java.util.Date. It’s much easier to use and finally offers separate classes representing date, date with time … | Continue reading
The post Book Review: DuckDB in Action appeared first on Thorben Janssen. What if I told you that there’s a tool that makes it incredibly easy to process datasets from various sources, analyze them using SQL, and export the result in different formats? And that it doesn’t require … | Continue reading
The post FetchType: Lazy/Eager loading for Hibernate & JPA appeared first on Thorben Janssen. Choosing the right FetchType is one of the most important decisions when defining your entity mapping. It specifies when your JPA implementation, e.g., Hibernate, fetches associated enti … | Continue reading
The post How to generate DAOs and queries with Hibernate appeared first on Thorben Janssen. Executing a query with Hibernate requires several lines of repetitive boilerplate code, and many developers have complained about that for years. You have to instantiate a Query object and … | Continue reading
The post How to implement a soft delete with Hibernate appeared first on Thorben Janssen. In some applications, you don’t want to or are not allowed to remove a record from the database permanently. But you still need to remove or hide records which are no longer active. One exam … | Continue reading
The post 11 JPA and Hibernate query hints every developer should know appeared first on Thorben Janssen. JPA and Hibernate support a set of hints that you can use to provide additional information to your persistence provider to influence the execution of a query. You can use the … | Continue reading
The post Inheritance Strategies with JPA and Hibernate – The Complete Guide appeared first on Thorben Janssen. Inheritance is one of the key concepts in Java. So, it’s no surprise that most developers want to use it in their domain model. Unfortunately, the relational table model … | Continue reading
The post TimezoneStorageType – Hibernate’s improved timezone mapping appeared first on Thorben Janssen. Working with timestamps with timezone information has always been a struggle. Since Java 8 introduced the Date and Time API, OffsetDateTime and ZonedDateTime have become the mo … | Continue reading
The post How to persist additional attributes for an association with JPA and Hibernate appeared first on Thorben Janssen. JPA and Hibernate allow you to define associations between entities with just a few annotations, and you don’t have to care about the underlying table… The p … | Continue reading
The post 8 things you need to know when migrating to Hibernate 6.x appeared first on Thorben Janssen. Hibernate 6 has been released for a while, and the latest Spring Data JPA version includes it as a dependency. So, it’s no surprise that… The post 8 things you need to know when … | Continue reading
The post Think twice before using an object mapping library to get your DTOs appeared first on Thorben Janssen. I often get asked if I can recommend any object mapping library to map entity objects to DTOs. And you can find several discussions and… The post Think twice before usi … | Continue reading
The post How to map composite column types with Hibernate appeared first on Thorben Janssen. When most developers design their table and entity models, they create tables that only use basic column types and map these to basic entity attributes.… The post How to map composite col … | Continue reading
The post Using Window Functions with Hibernate 5 & 6 appeared first on Thorben Janssen. SQL is an incredibly powerful query language. It provides sheer endless possibilities to extract and transform information. One example of that is a window function.… The post Using Window Fun … | Continue reading
The post Spring Data JPA – How to create a custom base repository appeared first on Thorben Janssen. Most developers create their own repositories by adding their queries to one of Spring Data JPA’s standard base repositories, like the JpaRepository or the CrudRepository. These r … | Continue reading
The post Java Records as Embeddables with Hibernate 6 appeared first on Thorben Janssen. Since the release of Java’s record feature, I got asked how you could use records with Hibernate. Until Hibernate 6, I had to tell you… The post Java Records as Embeddables with Hibernate 6 a … | Continue reading
The post The difference between Spring Data JPA’s findById, getOne, getById, and findOne methods appeared first on Thorben Janssen. Spring Data’s JpaRepository provides a huge set of methods that simplify the implementation of your database operations. You can use them to persist … | Continue reading
The post Hibernate Performance Tuning – 2023 Edition appeared first on Thorben Janssen. Based on most discussions online and at conferences, there seem to be 2 kinds of projects that use Hibernate for their persistence layer. Most use… The post Hibernate Performance Tuning – 2023 … | Continue reading
The post Entity Views with Blaze Persistence – The better DTO projections? appeared first on Thorben Janssen. Blaze Persistence’s Entity Views try to solve some of the most common complaints about DTO projections in JPA and Hibernate. Most developers know that DTOs… The post Enti … | Continue reading
The post Migrating to Hibernate 6 appeared first on Thorben Janssen. Hibernate 6 has been released for a while, and I see more and more teams migrating their persistence layers or at least preparing for the… The post Migrating to Hibernate 6 appeared first on Thorben Janssen. | Continue reading
The post Create better Criteria queries with Blaze persistence appeared first on Thorben Janssen. The Blaze Persistence project provides an interesting alternative to JPA’s Criteria API. Both APIs enable you to define queries dynamically at runtime. Most developers use… The post … | Continue reading
The post 6 Performance Pitfalls when using Spring Data JPA appeared first on Thorben Janssen. Thanks to its ease of use, Spring Data JPA is an incredibly popular persistence framework. If developers have something to complain about, they usually criticize… The post 6 Performance … | Continue reading
The post Database portability – Pitfalls when supporting multiple RDBMS with Hibernate appeared first on Thorben Janssen. The JPA specification and Hibernate, as its most popular implementation, claim to provide database portability. That means you don’t need to change your persi … | Continue reading
The post The differences between Spring Data JPA’s save, saveAndFlush and saveAll methods appeared first on Thorben Janssen. Spring Data JPA’s standard repositories provide a set of methods that handle common operations used by most persistence layers. That saves us a lot of… The … | Continue reading
The post How to use PostgreSQL’s JSONB data type with Hibernate appeared first on Thorben Janssen. Most databases offer lots of proprietary features in addition to the known SQL standard. One example is PostgreSQL’s JSONB data type which allows you to… The post How to use Postgre … | Continue reading
The post Spring Data JDBC – Use a sequence to generate primary keys appeared first on Thorben Janssen. By default, Spring Data JDBC expects the database to provide a primary key value for every new record. The easiest way to achieve that is… The post Spring Data JDBC – Use a sequ … | Continue reading
The post How to generate UUIDs as primary keys with Hibernate appeared first on Thorben Janssen. Most developers prefer numerical primary keys because they are efficient to use and easy to generate. But that doesn’t mean that a primary key has… The post How to generate UUIDs as p … | Continue reading
The post Flyway – Implementing Java-based Migrations and Callbacks appeared first on Thorben Janssen. Flyway’s SQL-script based database migration is more than powerful enough for most use cases. But sometimes, you must take it one step further to adapt… The post Flyway – Impleme … | Continue reading
The post Spring Data JDBC – Modelling and working with aggregates appeared first on Thorben Janssen. Entities, aggregates, and aggregate roots are some of the core concepts used by Spring Data JDBC. Based on them, Spring Data JDBC decides which objects… The post Spring Data JDBC … | Continue reading