spring-boot 1.5.6 RELEASE
을 사용 중입니다. 기본적인 것을하고 싶습니다. 저장소에있는 @Query
주석의 쿼리를 xml 파일로 옮기고 싶습니다.봄 부팅 응용 프로그램에서 외부 화 쿼리
약간의 읽기 후에는 orm.xml
또는 jpa-named-queries.properties
을 사용하여 사용자 정의 쿼리를 작성할 수 있다고 생각했습니다.
이 XML 파일의 위치를 파일 구조로 이해하지 못합니다. 그리고 내 프로젝트에는 META-INF
폴더가 없습니다.
예 :
POJO 클래스 :
@Entity
public Class Customer {
private int id;
private String name;
// getters and setters
}
저장소 :
public interface CustomerRepository extends PagingAndSortingRepository<Customer,Integer> {
// this query I need from an external xml file as it might be quite complex in terms of joins
@Query("Select cust from Customers cust")
public List<Customer> findAllCustomers();
}
EDIT : this stackoverflow question 언급했다. META-INF
폴더가 없으므로이 파일 (orm.xml
및 persistence.xml
)을 저장할 위치를 알아야합니다.
미리 감사드립니다.
[스프링 데이터 JPA에서 명명 된 쿼리에 XML 구성을 사용하는 방법] (https://stackoverflow.com/questions/24931248/how-to-use-xml-configuration-for-named-queries-in- spring-data-jpa) – Todd
예, 저는이 질문을 접했습니다. 그러나 제가 언급했듯이,'META-INF' 폴더가 없으며,이'properties/xml' 파일을 어디에 저장해야하는지에 대해 매우 혼란 스럽습니다. @Todd – Anusha
https://github.com/eclipse/examples/tree/master/jpa/employee.dynamic/src/main/resources/META-INF 및 http://webdev.jhuep.com/에서 github 예제를 확인하십시오. ~ jcs/ejava-javaee/coursedocs/605-784-site/docs/content/html/hibernate-migration-orm.html, META-INF가 없으면 작성해야합니다. –