组合Spring Data查询的属性解释不正确

时间:2015-06-08 13:42:36

标签: jpa spring-data spring-data-jpa datanucleus

我有以下课程

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处遇到了相同的错误。

0 个答案:

没有答案