# Spring Data JPA

Published articles for Spring Data JPA.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## The best way to clean up test data with Spring and Hibernate

DevFeed: [The best way to clean up test data with Spring and Hibernate](<https://devfeed.tech/articles/the-best-way-to-clean-up-test-data-with-spring-and-hibernate-21982.md>)

Original publisher: [Read original article](<https://vladmihalcea.com/clean-up-test-data-spring/>)

Author: vladmihalcea

Published: 2025-11-11T08:05:24Z

Content type: article

Language: en

Sources: [Vlad Mihalcea](<https://devfeed.tech/sources/vlad-mihalcea.md>)

Topics: [Hibernate](<https://devfeed.tech/topics/hibernate.md>), [Software Testing](<https://devfeed.tech/topics/software-testing.md>), [Spring Framework](<https://devfeed.tech/topics/spring-framework.md>), [Spring Boot](<https://devfeed.tech/topics/spring-boot.md>), [test data](<https://devfeed.tech/topics/test-data.md>), [Test automation](<https://devfeed.tech/topics/test-automation.md>)

Tags: [batching](<https://devfeed.tech/tags/batching.md>), [best-practices](<https://devfeed.tech/tags/best-practices.md>), [cleanup](<https://devfeed.tech/tags/cleanup.md>), [hibernate](<https://devfeed.tech/tags/hibernate.md>), [integration-testing](<https://devfeed.tech/tags/integration-testing.md>), [jpa](<https://devfeed.tech/tags/jpa.md>), [logging](<https://devfeed.tech/tags/logging.md>), [schema](<https://devfeed.tech/tags/schema.md>), [spring](<https://devfeed.tech/tags/spring.md>), [spring-boot](<https://devfeed.tech/tags/spring-boot.md>), [spring-data-jpa](<https://devfeed.tech/tags/spring-data-jpa.md>), [test](<https://devfeed.tech/tags/test.md>), [test-data](<https://devfeed.tech/tags/test-data.md>), [testing](<https://devfeed.tech/tags/testing.md>), [truncatemappedobjects](<https://devfeed.tech/tags/truncatemappedobjects.md>)

### AI overview

The excerpt recommends avoiding `@DataJpaTest` when its default test behavior gets in the way of better SQL logging or realistic transaction handling. It says the annotation auto-configures JPA-related Spring beans, logs SQL to the console, and wraps each test in a transaction that is rolled back afterward. The author argues Spring's SQL logging property cannot show bind values or whether batching is used, and recommends DataSource-Proxy for richer logging and automatic detection of N+1 query issues during tests. The excerpt begins to explain problems with rollback-based test transactions but cuts off before giving the proposed cleanup approach, so it does not establish the article's full recommendation for cleaning test data.

### Source excerpt

Introduction In this article, I'm going to show you the best way to clean up test data when using Spring and Hibernate. While it's very common to use the @DataJpaTest annotation when implementing integration tests, in this blog post, you will see why you are better off avoiding using this annotation. Why I don't use @DataJpaTest As explained by the manual, Spring Boot provides the @DataJpaTest annotation for Spring Data JPA integration testing. Once the @DataJpaTest annotation is added to an integration test, Spring Boot will make the following changes to the... Read More The post The best way to clean up test data with Spring and Hibernate appeared first on Vlad Mihalcea.

## The Second Best Way to Fetch a Spring Data JPA DTO Projection

DevFeed: [The Second Best Way to Fetch a Spring Data JPA DTO Projection](<https://devfeed.tech/articles/the-second-best-way-to-fetch-a-spring-data-jpa-dto-projection-28966.md>)

Original publisher: [Read original article](<https://blog.jooq.org/the-second-best-way-to-fetch-a-spring-data-jpa-dto-projection/>)

Author: lukaseder

Published: 2022-08-30T14:48:44Z

Content type: tutorial

Language: en

Sources: [jOOQ](<https://devfeed.tech/sources/jooq.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [Spring Boot](<https://devfeed.tech/topics/spring-boot.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [dto-projection](<https://devfeed.tech/tags/dto-projection.md>), [jooq](<https://devfeed.tech/tags/jooq.md>), [jooq-in-use](<https://devfeed.tech/tags/jooq-in-use.md>), [nested-collections](<https://devfeed.tech/tags/nested-collections.md>), [repositories](<https://devfeed.tech/tags/repositories.md>), [spring-boot](<https://devfeed.tech/tags/spring-boot.md>), [spring-data-jpa](<https://devfeed.tech/tags/spring-data-jpa.md>)

### AI overview

The article presents jOOQ as a second way to implement a Spring Data JPA DTO projection. It shows value-constructor and aggregate-function approaches, emphasizing type-safe record conversion and reduced infrastructure code.

### Source excerpt

I've just stumbled upon this great post by Vlad Mihalcea, titled The Best Way to Fetch a Spring Data JPA DTO Projection. It got some nice traction on reddit, too. This is such a nice use-case and apt solution, I wanted to quickly show the second best way of doing the same, with jOOQ this ... Continue reading The Second Best Way to Fetch a Spring Data JPA DTO Projection ->