IllSc
IllSc

Reputation: 1459

Parameter value did not match expected type (Spring Data JPA)

Let's say I have class A and B

public class A{
@Id
String id;
private B b;
}

public class B{
@Id
String id;
private List<A> a;
}

I'm using @Queryfor my query since my query is too long for Query creation .

@Query("select a from A a where  b = :b")
public List<A> findSomething(@Param("b") String bId);

However, when I use that query it shows

Parameter value  did not match expected type [B (n/a)]

Upvotes: 2

Views: 3350

Answers (1)

Abhinay
Abhinay

Reputation: 474

Please change query to "select a from A a where a.b.id = :b". It will work

Upvotes: 4

Related Questions