Raffa:
私は別のエンティティから継承そのエンティティの春データのJPAリポジトリを設定しようとしています。
私は春データJPAと春ブーツ2.1.6を使用しています。私はすでにこの問題を調査し、ドキュメントを見て、私は、見つかった例は似ていますが、どれも非常によく、私たちは、エンティティの継承を持っているとき、クラスのためのリポジトリを処理する方法を示しませんでした。
ここで私は、メインクラスを持っています:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class Person implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
// Getters and setters omitted
}
そして、ここにクラスの人から継承していること:
@Entity
@PrimaryKeyJoinColumn(name="id")
public class Driver extends Person {
private String vehicleModel;
// Getters and setters omitted
}
私は、フィルタを作成して、リポジトリで使用します:
public class DriverFilter {
private String vehicleModel;
// Getters and setters omitted
}
私が作成した後DriverQueriesインタフェース:
public interface DriverQueries {
public Page<Driver> filter(DriverFilter filter, Pageable pageable);
}
そして私は、その実装を行いました。
public class DriverImpl implements DriverQueries {
@Override
public Page<Driver> filter(DriverFilter filter, Pageable pageable) {
// code omitted
}
}
私はベースのリポジトリを作成します。
@NoRepositoryBean
public interface People<T extends Person> extends JpaRepository<T, Long> {
}
そして最後に、私は継承されたクラスのリポジトリを作成します。
@Repository
public interface Drivers extends People<Driver>, DriverQueries {
}
私はプログラムを実行するときしかし、私は次の例外があります。
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property filter found for type Driver!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:94)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:382)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:358)
at org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:311)
at java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:324)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:293)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:276)
at org.springframework.data.repository.query.parser.Part.<init>(Part.java:81)
at org.springframework.data.repository.query.parser.PartTree$OrPart.lambda$new$0(PartTree.java:250)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:251)
at org.springframework.data.repository.query.parser.PartTree$Predicate.lambda$new$0(PartTree.java:380)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:381)
at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:93)
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:78)
... 103 common frames omitted
私は通常のクラスのリポジトリを作成する場合は、前回と同じロジック以下、すべてが完璧に動作します。
誰もが間違っている可能性が何を知っていますか?
ありがとうございました!
Serg Zenyuk:
このエラーは、私たちがクラスに割り当てられている場合が消えDriverImplその親(類推して、正しい名前をDriverQueries) - DriverQueriesImplを。この場合は、継承されたクラスは親プラスsufixと呼ばれるものとするImpl。
春はこの上厳しいです。