I'm looking to implement this query as a Specification for a Spring Data repository:
select * from Parts where id not in (select partId from PartsToDeliveries where deliveryId = 31) (Basically, find all the parts that were not part of a certain delivery)
Here are the classes:
@Entity public class Part { @Id private Long id; @ManyToMany @JoinTable(name = "PartsToDeliveries", joinColumns = {@JoinColumn(name = "partId")}, inverseJoinColumns = @JoinColumn(name = "deliveryId")) private Set<Delivery> deliveries = new HashSet<>(); } and
@Entity public class Delivery { @Id private Long id; @ManyToMany(mappedBy = "deliveries") private List<Part> parts; } Fill in the blank:
Specification<Part> specification = (root, criteriaQuery, criteriaBuilder) -> { ? _______ ? } I simply don't know where to start on this.