Creating a Spring Read Only and Native Query
To allow your query methods to be transactional, you should use @Transactional at the repository interface that you define. For reading operations, the transaction configuration readOnly flag should be set