我正在尝试使用@SqlResultSetMapping 和@ConstructorResult 将存储过程的结果映射到非实体POJO。这是我的代码:
@MappedSuperclass
@SqlResultSetMapping(name = "Testing", classes = @ConstructorResult(targetClass = Testing.class, columns = {
@ColumnResult(name = "TTEAM_ID", type = Integer.class),
@ColumnResult(name = "VDATE", type = BigInteger.class),
@ColumnResult(name = "Days_in_Field", type = Integer.class),
@ColumnResult(name = "Expected_cummilative_Number_of_HH", type = Integer.class),
@ColumnResult(name = "Cummlative_HH_Reached",type = Integer.class),
@ColumnResult(name = "HH_Reached_for_day",type = Integer.class),
@ColumnResult(name = "HHs_Finalised_for_day", type = Integer.class),
@ColumnResult(name = "Number_of_HH_in_process_for_day", type = Integer.class),
@ColumnResult(name = "Number_of_HH_Refused_for_day",type = Integer.class),
@ColumnResult(name = "Number_of_Revisits_Scheduled_for_day", type = Integer.class),
@ColumnResult(name = "HH_loss_3rd_visit_attempt_refusals_for_day", type = Integer.class)}))
public class Testing {
private Integer tteam_id;
private Integer vdate;
private Integer days_in_field;
private Integer Expected_cummilative_Number_of_HH;
private Integer Cummlative_HH_Reached;
private Integer HH_Reached_for_day;
private Integer HHs_Finalised_for_day;
private Integer Number_of_HH_in_process_for_day;
private Integer Number_of_HH_Refused_for_day;
private Integer Number_of_Revisits_Scheduled_for_day;
private Integer HH_loss_3rd_visit_attempt_refusals_for_day;
public Testing(Integer tteam_id,
Integer vdate,
Integer Expected_cummilative_Number_of_HH,
Integer Cummlative_HH_Reached,
Integer HH_Reached_for_day,
Integer HHs_Finalised_for_day,
Integer Number_of_HH_in_process_for_day,
Integer Number_of_HH_Refused_for_day,
Integer Number_of_Revisits_Scheduled_for_day,
Integer HH_loss_3rd_visit_attempt_refusals_for_day ) {
this.tteam_id = tteam_id;
this.vdate = vdate;
this.Expected_cummilative_Number_of_HH = Expected_cummilative_Number_of_HH;
this.Cummlative_HH_Reached = Cummlative_HH_Reached;
this.HH_Reached_for_day = HH_Reached_for_day;
this.HHs_Finalised_for_day = HHs_Finalised_for_day;
this.Number_of_HH_in_process_for_day = Number_of_HH_in_process_for_day;
this.Number_of_HH_Refused_for_day = Number_of_HH_Refused_for_day;
this.Number_of_Revisits_Scheduled_for_day = Number_of_Revisits_Scheduled_for_day;
this.HH_loss_3rd_visit_attempt_refusals_for_day = HH_loss_3rd_visit_attempt_refusals_for_day;
}
//getter and setters
然后调用我的存储过程
public List<Testing> getDailyAchievements(){
List list;
StoredProcedureQuery query = entityManager.createStoredProcedureQuery("dailyreports", "Testing");
try {
// Execute query
query.execute();
list = query.getResultList();
} finally {
try {
query.unwrap(ProcedureOutputs.class).release();
} catch (Exception e) {
}
}
return list;
}
我最终得到了错误
无法在类上找到适当的构造函数:com.ram.Testing
在尝试调试应用程序后,我最终得到了错误
com.microsoft.sqlserver.jdbc.SQLServerException:语句已关闭。
我找到了一些资源,包括这个:@ConstructorResult 映射但我仍然没有任何运气。
我错过了什么?为什么找不到构造函数?