Giả sử tôi có tổ chức (getters/setters và chi tiết khác nhau bỏ qua cho ngắn gọn):mùa xuân truy vấn dữ liệu mà cột là null
@Entity
class Customer{
...
@OneToMany(cascade = CascadeType.ALL, mappedBy = "customer")
Collection<Coupon> coupons;
}
@Entity
class Coupon{
...
@Temporal(value = TemporalType.TIMESTAMP)
private Date usedOn;
@ManyToOne(fetch = FetchType.LAZY)
@NotNull
Customer customer;
}
Tôi muốn lấy tất cả các phiếu giảm giá cho một khách hàng cho có vô usedOn. tôi, đã không thành công được xác định một phương pháp trong CouponRepository như mô tả trong docs
@Repository
public interface CouponRepository extends CrudRepository<Coupon, Long> {
Collection<Coupon> findByCustomerAndUsedOnIsNull(Customer);
}
nhưng điều này dẫn vào một lỗi biên dịch Syntax error, insert "... VariableDeclaratorId" to complete FormalParameterList
.