I have a lengthy native query with several conditions and joins which runs into 25 lines.
Right now, I have it as an @Query
annotation right near the method name in a Spring Data JPA repository interface.
What is the best way to externalize this in a Spring Boot project?
I had a look at entity named queries. However, it looks like the purpose there is different. Seems it is for attaching named queries with the Entity so that the query can be referred within JPA Queries in concise manner.
I have in the past used ClassPathResource
s to store static files like JSON responses for the purpose of testing. But, haven't come across a similar solution for Spring Data native queries.