Ich versuche, die Projektion mit der Spezifikation in Spring Data JPA über diese Umsetzung zu implementieren:Implementierung Projektion mit Spezifikation in Spring Data JPA
https://github.com/pramoth/specification-with-projection
Verwandte Klassen sind wie folgt:
Spec:
public class TopicSpec {
public static Specification<Topic> idEq(String id){
return (root, query, cb) -> cb.equal(root.get(Topic_.id),id);
}
}
Repository
-Test
@Test
public void specificationWithProjection() {
Specification<Topic> where= Specifications.where(TopicSpec.idEq("Bir"));
List<Topic> all = topicRepository.findAll(where);
Assertions.assertThat(all).isNotEmpty();
}
Ich habe diese Antwort von der Get-Methode:
jedoch die Tests fehlschlagen. Nebenbei, wenn ich das Github-Projekt von Pramoth ziehe, kann ich die Tests mit Erfolg durchführen. Hat jemand eine Meinung zu diesem Thema?
Das vollständige Projekt finden Sie hier: https://github.com/dengizik/projectionDemo