Reputation: 1675
I am using the following implementation of Crud Repository, where I need to find if MyObject contains a reference to OtherObject.
public interface MyRepository extends CrudRepository<MyObject, Long> {
List<MyObject> findByOtherObject(Long id);
}
This is how I map my entity:
@Entity
@Table(name = "mytable")
public class MyObject {
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "object_id")
private OtherObject otherObject;
}
And the error I am getting:
java.lang.IllegalArgumentException: Parameter value [3] did not match expected type
This shows that I am mapping incorrectly between my Entity and my Repository. But I do not want to change the name of the column.
It does not work if I change the repository method to findByObject_Id. Any suggestion?
Upvotes: 0
Views: 327