Test a Native Query of Your Spring Data JPA Repository With @DataJpaTest

Опубликовано: 18 Май 2026
на канале: Philip Riecks
4,079
38

This is the third video of the @DataJpaTest mini-series. We'll test our native query that uses the proprietary JSON feature of PostgreSQL with a custom test setup.

Part I:    • Introduction to @DataJpaTest and Pitfalls ...  
Part II:    • Replacing the Default In-Memory Database o...  
Part III:    • Test a Native Query of Your Spring Data JP...  
Part IV:    • Short And Concise Test Setup With @DataJpa...  

Source code: https://github.com/rieckpil/blog-tuto...

Content:

0:00 Start writing the test for our native query
1:07 Pre-populating data for our test
3:30 Writing the assertion for our test
4:14 Inspecting the log output of our test

More testing related content is available on my blog: https://rieckpil.de/

» For more deep-dive into testing your Spring Boot persistence layer, consider joining the Testing Spring Boot Applications Masterclass: https://rieckpil.de/testing-spring-bo...

» Revamp your Testing Knowledge with this 14 Days Free Email Course on Testing Java Applications: https://rieckpil.de/getting-started-w...

#DataJpaTest #NativeQuery #PostgreSQL