2017-12-12 7 views
0

エンティティのページおよびソートされたリストを返すメソッドを作成したいと思い、Spring Dataがメソッド名から直接クエリを派生できることを期待していました。 1つのモジュールで使用すると、共有モジュールの次のリポジトリ定義がうまく機能し、別のモジュールで使用されたときに「コンテキストの初期化に失敗しました」というエラーが発生します。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に依存します。 2番目のモジュールは古いもので、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); 
} 

を。

関連する問題