JPA Query Exception以使用join获取数据

时间:2013-10-01 06:15:14

标签: java jpa

Dao班

@Query("select pt from com.ctpm.rrh.basket.model.user.User as u  inner join u.userPaymentTransaction as pt where u = ?")
    List<UserPaymentTransaction> findPaymentTransactionforUser(User user);

控制台上的QueryException

  

`org.hibernate.QueryException:无法解析属性:userPaymentTransaction:com.ctpm.rrh.basket.model.user.User [从com.ctpm.rrh.basket.model.user.User中选择pt为你内部联接u.userPaymentTransaction为pt,其中u =?]

UserPaymentTransaction类有

@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    private Money amount;

    private String description;

    @NotNull
    @OneToOne(cascade = CascadeType.MERGE)
    User owningUser;

    private Date transactionDate;

请帮忙

1 个答案:

答案 0 :(得分:0)

我认为您的查询应该是这样的: -

@Query("select pt from UserPaymentTransaction pt where pt.owningUser = ?1")