假設我有實體(getter/setter方法,並略去了各種細節):春數據查詢,其中列爲空
@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;
}
我希望檢索所有優惠券具有空usedOn一個給定的客戶。 I,'已經如在docs
@Repository
public interface CouponRepository extends CrudRepository<Coupon, Long> {
Collection<Coupon> findByCustomerAndUsedOnIsNull(Customer);
}
描述,但是這將導致在一個編譯錯誤Syntax error, insert "... VariableDeclaratorId" to complete FormalParameterList
在CouponRepository不成功定義的方法。