2017-12-12 2 views
0

페이징되고 정렬 된 엔티티 목록을 반환하는 메서드를 작성하려고했습니다. Spring Data이 메서드 이름에서 직접 쿼리를 파생시킬 수 있기를 기대했습니다. 하나의 모듈에서 사용되면 공유 모듈의 다음 저장소 정의가 잘 작동하고 다른 모듈에서 사용될 때 "컨텍스트 초기화 실패"오류로 실패합니다.OrderBy가 이전 Spring 데이터에서 오류가 발생합니다.

@Repository 
public interface AppleDao extends JpaRepository<Apple, Long> { 
    Page<Apple> getAllByVarietyEqualsOrderById(Variety variety, Pageable pageable); 
} 

첫 번째 모듈은 최신이며 Spring Data JPA 1.11.0 + Spring Data Commons 1.13.0에 따라 다릅니다. 두 번째 모듈은 이전 버전이며 Spring Data JPA 1.6.2 + Spring Data Commons 1.8.2에 의존합니다. 이 오류없이 봄 데이터의 모든 버전에서 작동하므로

SEVERE: Context initialization failed 
org.springframework.beans.factory.BeanCreationException: 
    Error creating bean with name 'appleServiceImpl': Injection of autowired dependencies failed; 
    nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private by.naxa.dao.apple.AppleDao by.naxa.services.apple.AppleServiceImpl.appleDao; 
    nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appleDao': Invocation of init method failed; 
    nested exception is java.lang.IllegalArgumentException: Could not create query metamodel for method public abstract org.springframework.data.domain.Page by.naxa.dao.apple.AppleDao.getAllByVarietyEqualsOrderById(by.naxa.entity.apple.Variety,org.springframework.data.domain.Pageable)! 
    Invalid order syntax for part Id 

방법이 방법을 다시 작성 :

여기에 로그의 조각인가?

답변

0

, 아무것도 재 작성 단지 명시 적 정렬 순서를 지정할 필요가 없습니다 : 당신 때문에 ( 봄 데이터 가공 1.10 고정) DATACMNS-641이 오류가 발생

@Repository 
public interface AppleDao extends JpaRepository<Apple, Long> { 
    Page<Apple> getAllByVarietyEqualsOrderByIdAsc(Variety variety, Pageable pageable); 
} 

합니다.