I\'m using spring
with CrudRepository
s for database connection.
Now I require a quite long (several lines) sql query that I\'d prefer to ma
Not sure if it fits your setup, but, this can be done by :
1) Adding your query to a hibernate mapping file using the
tag
.......
2) Define a hibernate config file that includes the above file using the
tag
3) Defining a persistence file with a property "hibernate.ejb.cfgfile"
that points to the above config file
4) Use the above property file to build the EntityManagerFactory
Now, the above Query can be used in the Repository method :
@Query(name = "MyQuery", nativeQuery = true)
[return type] executeMyQuery();