I have two entities like A and B such that:
 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
 }
I have a spring data repository such that:
 @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);
But I am getting the exception, no parameter binding found for name b!.
However, if I modify the above query as:
@Query("from A a where a.b.id =:#{#b.id}")
A findByB(@Param(value = "b") B b);
all works fine. What's the issue with this.
It seems that we must use SPeL for all parameters in the query, not mixing jpa ways and SPel : :date mixed with :#{#b.id}.
Try this, I have not tested I don't know how it would behave with a Date :
 @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);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With