/**
方式一
**/
@Override
public List getDataStatistics(String sql, Page.Offset offset, String ... params )
{
SQLQuery sqlQuery = getCurrentSession().createSQLQuery(sql);
int i = 0;
for(int len = params.length; i < len; i++)
{
sqlQuery.setParameter(i, params[i]);
}
sqlQuery.setParameter(i++, offset.getStart());
sqlQuery.setParameter(i++, offset.getLimit());
List result = (List)sqlQuery.setResultTransformer(new ResultTransformer()
{
@Override
public Object transformTuple(Object[] tuple, String[] aliases)
{
return null;
}
@Override
public List transformList(List collection)
{
return null;
}
});
return result;
}
/**
方式二
**/
@Override
public List getDataStatistics(String sql, Page.Offset offset, String ... params ){
SQLQuery sqlQuery = getCurrentSession().createSQLQuery(sql);
int i = 0;
for(int len = params.length; i < len; i++)
{
sqlQuery.setParameter(i, params[i]);
}
sqlQuery.setParameter(i++, offset.getStart());
sqlQuery.setParameter(i++, offset.getLimit());
return sqlQuery.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE).list();
}
/**
方式三
**/
/**
* 记录总的条数统计
*/
@Override
public long getSumOfDataTotal(String sql, Object... params)
{
SQLQuery sqlQuery = getCurrentSession().createSQLQuery(sql);
for(int i = 0, len = params.length; i < len; i++)
{
sqlQuery.setParameter(i, params);
}
return Long.valueOf(sqlQuery.uniqueResult().toString());
}