Reputation: 568
I Have this entity classes:
public class Work implements java.io.Serializable {
private Integer workId;
private User userByCreateBy;
private User userByUpdateBy;
private Long studyId;
private String name;
private byte panelType;
private byte status;
private Date createDate;
private Date updateDate;
private Set<Task> tasks = new HashSet<Task>(0);
public Work() {
}
}
private Integer taskId;
private User userByCompleteBy;
private User userByExecutedBy;
private Work work;
private byte type;
private Date startDate;
private Date endDate;
private byte status;
private Date updateDate;
private Forecast forecast;
private Set<ForecastOutput> forecastOutputs = new HashSet<ForecastOutput>(0);
private MonitorLottery monitorLottery;
private QprMonitorLotteryArea qprMonitorLotteryArea;
private Set<QprMonitorLotteryOutput> qprMonitorLotteryOutputs = new HashSet<QprMonitorLotteryOutput>(0);
private Set<ForecastCellafter740> forecastCellafter740s = new HashSet<ForecastCellafter740>(0);
private Set<QprMonitorLotteryResult> qprMonitorLotteryResults = new HashSet<QprMonitorLotteryResult>(0);
private Set<AnswerDataOutput> answerDataOutputs = new HashSet<AnswerDataOutput>(0);
private QprMonitorLottery qprMonitorLottery;
private AnswerDataCheck answerDataCheck;
public Task() {
}
}
public class User implements java.io.Serializable {
private Integer userId;
private String userName;
private String password;
private String name;
private String email;
private byte authority;
private Date lastLogin;
private Date passwordChangeDate;
private byte status;
private Integer createBy;
private Integer updateBy;
private Date createDate;
private Date updateDate;
private Set<MasterFile> masterFiles = new HashSet<MasterFile>(0);
private Set<Task> tasksForCompleteBy = new HashSet<Task>(0);
private Set<Work> worksForCreateBy = new HashSet<Work>(0);
private Set<Work> worksForUpdateBy = new HashSet<Work>(0);
private Set<Task> tasksForExecutedBy = new HashSet<Task>(0);
public User() {
}
}
I want to join this tables using hql and get the details of username,workname,task.type,task.status etc.. I have done this code
StringBuilder dataQuery = new StringBuilder("select new com.web.main.view.WorkView("
+ "w.workId, "
+ "w.studyId, "
+ "w.name, "
+ "w.panelType, "
+ "t.type, "
+ "t.status, "
+ "u.user_name,"
+ "w.createDate, "
+ "w.updateDate, "
+ "t.startDate, "
+ "t.endDate ) "
+ "from Work w left join w.tasks t left join w.user u where u.user_Id = w.create_by and w.status!=:status");
But it is given the error
HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: user of,
What will be the issue am I doing something wrong
Upvotes: 0
Views: 413
Reputation: 244
There is no field named user
on the Work
entity. So you should replace w.user
with w.userByCreateBy
or w.userByUpdateBy
(or rename entity field).
Upvotes: 1
Reputation: 7622
In Work entity I dont see user field you have
private User userByCreateBy;
private User userByUpdateBy;
private User userByCompleteBy;
private User userByExecutedBy;
Problem is in this line
left join w.user u where u.user_Id = w.create_by
You need to have User List in Work to left join same like Task
Upvotes: 0