Externalize query in spring boot application

前端 未结 1 909
Happy的楠姐
Happy的楠姐 2021-01-07 14:07

I am using spring-boot 1.5.6 RELEASE. I want to do a basic thing, move my queries from the @Query annotation in the repository to any xml file.

1条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-07 14:28

    Create META-INF inside resources folder . Now create jpa-named-queries.properties file inside that META-INF folder.

    Write your query inside this properties file like this:

    Customer.findAllCustomerByNamedQuery=Select c from Customer c

    Where Customer denote name of entity class and findAllCustomerByNamedQuery is the query name

    In your customer repository write this to call your query written in properties file:

    List findAllCustomerByNamedQuery();

    0 讨论(0)
提交回复
热议问题