Complex native queries stored in separate files with Spring Data JPA

52 views Asked by At

I am working with Spring Data JPA to retrieve data from Oracle database. I wanted to use complex and quite large native SQL queries in my application. Using @Query on the method signature and writing my query there was not the best option since my repository would grow larger and larger over time.

I need to store these queries in a separate SQL files where I can retrieve them and execute my query.

Is there any approach to achieve this? I need to reduce the boilerplate in my application and make it as readable as possible.

I have tried using named queries but that made my java could almost doubled. And tried storing them in a single META-INF/~.properties file but that would lead to a large file filled with queries

If there is any approach to handle complex queries, or any best practices or standards, please let me know.

Thanks in advance!

0

There are 0 answers