我有兩個實體,例如A和B這樣的:沒有參數綁定發現名稱(春季數據JPA)
class B {
private Integer id;
private String field1;
private String field2;
// getters and setters
}
class A {
private Date date;
//one to one mapping is there between A and B
private B b;
//getters and setters
}
我有一個春天的數據存儲庫這樣的:
@Query("from A a where a.date= :date and a.b.id =:#{#b.id}")
A findByBAndDate(@Param(value = "date") Date date,@Param(value = "b") B b);
但我我得到了例外,no parameter binding found for name b!
。
但是,如果我修改上面的查詢爲:
@Query("from A a where a.b.id =:#{#b.id}")
A findByB(@Param(value = "b") B b);
一切工作正常。這有什麼問題。
它的正常工作與 @Query(「從一個地方阿比德=#{# b.id}「) findByB(@Param(value =」b「)B b);由於spring爲spring數據提供了SPEL支持,因此請仔細閱讀該問題。 – user1157635