Hibernate连接查询:无法解析该属性

时间:2013-07-09 08:20:30

标签: hibernate

我有两个模型类UserDetail& TempDataDetail 我在UserDetails模型类中创建了TempDataDetails的对象 tempDataDetails ,并在TempdataDetails中创建了UserDetails的 userDetails

我的join hql查询是“来自UserDetails userDetailsjoin userDetails.TempdataDetails tempDataDetails,其中userDetails.snrno = tempDataDetails.snrno ”并且在执行此查询时导致错误: TempdataDetails无法解析该属性

我已将查询更改为:

我的连接hql查询是“来自TempdataDetails tempDataDetails join tempDataDetails.UserDetails userDetailswhere tempDataDetails.snrno = userDetails.snrno ”,并且在执行此查询时导致错误: UserDetails无法解析该属性

我的getter()setter()是:


public class UserDetails{

    @OneToOne
    @PrimaryKeyJoinColumn
    private TempDataDetails tempDataDetails;

    public TempDataDetails getTempDataDetails() {
        return tempDataDetails;
    }

    public void setTempDataDetails(TempDataDetails tempDataDetails) {
        this.tempDataDetails = tempDataDetails;
    }
}

public class TempDataDetails{

    @OneToOne(mappedBy = "tempDataDetails", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private UserDetails userDetails;

    public UserDetails getUserDetails() {
        return userDetails;
    }

    public void setUserDetails(UserDetails userDetails) {
        this.userDetails = userDetails;
    }
}

1 个答案:

答案 0 :(得分:0)

Java区分大小写。这些字段的名称为tempDataDetailsuserDetails,而不是TempdataDetailsUserDetails