我有以下课程
public class User {
@Id
private Long id;
...
}
public class Review {
@Id
private Long id;
@ManyToOne
private User author;
@ManyToOne
private User givenTo;
...
}
public interface ReviewRepository extends CrudRepository<Review> {
Collection<Review> findByGivenToIdAndAuthorId(Long givenToId, Long authorId);
}
通过调用findByGivenToIdAndAuthorId
,我收到以下错误:
Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: Query has DN_THIS.givenTo.author yet author is not found. Fix your input; nested exception is javax.persistence.PersistenceException: Query has DN_THIS.givenTo.author yet author is not found. Fix your input
知道为什么吗?
我也尝试使用findByAuthorIdAndGivenToId
,但我在author.givenTo
处遇到了相同的错误。