块引用
我在hibernate中使用createSQLQuery()
。我将值存储在List<Student> studentList
中,但无法使用studentList.get(i).getStudentID();
从列表中获取值。它正在抛出NullPointerException
。但是,当我使用studentList.size()
打印列表大小时,它表示列表大小为8。
我做错了什么?
import java.io.Serializable;
import java.util.Date;
公共类EfwStageLog实现Serializable {
private static final long serialVersionUID = 1L;
private Integer stage_log_id;
private Date moment;
private Date end_time;
private String exec_status;
private int stage_id;
public Integer getStage_log_id() {
return stage_log_id;
}
public void setStage_log_id(Integer stage_log_id) {
this.stage_log_id = stage_log_id;
}
public Date getMoment() {
return moment;
}
public void setMoment(Date moment) {
this.moment = moment;
}
public Date getEnd_time() {
return end_time;
}
public void setEnd_time(Date end_time) {
this.end_time = end_time;
}
public String getExec_status() {
return exec_status;
}
public void setExec_status(String exec_status) {
this.exec_status = exec_status;
}
public int getStage_id() {
return stage_id;
}
public void setStage_id(int stage_id) {
this.stage_id = stage_id;
}
}
StageExecution.java
public class StageExecution extends ActionSupport{
private static final long serialVersionUID = 1L;
List<EfwStageLog> stagelogList;
EfwStageLog efwstagelog;
EfwStageExecutionManager stageexecutionmnager;
public String execute() {
return SUCCESS;
}
public StageExecution()
{
stageexecutionmnager = new EfwStageExecutionManager();
}
public String AverageStageWiseExecution()
{
System.out.println("I m in avgSWE+++++++++++++++++++++");
efwstagelog = new EfwStageLog();
stagelogList = stageexecutionmnager.getAverageStageExecutionDetail(stagelogList);
System.out.println("stagelogList.size============"+stagelogList.size());
return SUCCESS;
}
}
EfwStageExecutionManager.java
public class EfwStageExecutionManager {
List <EfwStageLog> stageLogList;
@SuppressWarnings("unchecked")
public List<EfwStageLog> getAverageStageExecutionDetail(List<EfwStageLog> efwstageLog)
{
System.out.println("I am in getLastStageExecutionDetail=========");
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
efwstageLog =session.createSQLQuery("select stage_id,(def/c) as ax from ((select stage_id,sum(end_time-moment) as def, COUNT(*) c,(sum(end_time-moment)/COUNT(*)) as man FROM efw_db.efw_stage_logs GROUP BY stage_id HAVING c > 1) as ab)").list();
efwstageLog.get(0).getStage_id();
}
}
我在点“efwstageLog.get(0).getStage_id();”
时收到错误HTTP状态500 - [Ljava.lang.Object;无法转换为com.helical.efw.model.EfwStageLog