【发布时间】:2015-11-11 09:24:07
【问题描述】:
我有以下类必须返回对象列表
private class getOfficeNumberQuery extends MappingSqlQuery<OfficeNumberVO>
{
private Log log = LogFactory.getLog(GetAccruedBalanceForAssociateQuery.class);
static private final String SQL = " SELECT b.xxxx AS associateMasterRecordId,a.zzz AS accruedHour, offices.yyy AS officeNumber "
+ " FROM table3 a, table1 b, table2 offices WHERE a.Aident = b.Aident AND offices.branchId = b.branchId AND (a.AvailableBalance <> 0.0000 OR a.AvailableBalance <> null) "
+ " AND offices.BranchName IN(?)) ";
public getOfficeNumberQuery(DataSource ds)
{
super(ds, SQL.toString());
super.declareParameter(new SqlParameter("BranchName", Types.VARCHAR));
try
{
compile();
}
catch (InvalidDataAccessApiUsageException e)
{
log.error("getOfficeNumberQuery(DataSource)", e); //$NON-NLS-1$
throw new StaffTrackSystemFailureException(e);
}
}
@Override
protected OfficeNumberVO mapRow(ResultSet rs, int rowNum) throws SQLException
{
OfficeNumberVO payInfo = new OfficeNumberVO() ;
payInfo.setAssociateMasterRecordId(rs.getLong("associateMasterRecordId"));
payInfo.setAccruedHour(rs.getLong("accruedHour"));
payInfo.setOfficeNumber(rs.getString("officeNumber"));
return payInfo;
}
}
如何修改此方法以返回对象列表
@Override
protected OfficeNumberVO mapRow(ResultSet rs, int rowNum) throws SQLException
{
OfficeNumberVO payInfo = new OfficeNumberVO() ;
payInfo.setAssociateMasterRecordId(rs.getLong("associateMasterRecordId"));
payInfo.setAccruedHour(rs.getLong("accruedHour"));
payInfo.setOfficeNumber(rs.getString("officeNumber"));
return payInfo;
}
还有人帮我写的SQL好不好?
环境:SQL Server
【问题讨论】:
标签: java sql sql-server mapping