How to store @Query sql in external file for CrudRepository?

前端 未结 3 558
遥遥无期
遥遥无期 2020-12-03 07:42

I\'m using spring with CrudRepositorys for database connection.

Now I require a quite long (several lines) sql query that I\'d prefer to ma

3条回答
  •  既然无缘
    2020-12-03 08:23

    if your project set up has resources folder, create under /META-INF/jpa-named-queries.properties file and add key value pair as repoClass.methodName=yoursql. Spring data will pick up.

    For longer queries it's probably best to use xml properties file with CDATA tags: https://stackoverflow.com/a/19128259/1194415

提交回复
热议问题