/**
* 带参数查询
* @param querypath sql语句路径
* @param args 参数--查询条件
* @return result
* @throws BussinessException
*/
public List queryparam(String querypath,Object...args) throws BussinessException {
List list;
int i = 0;
try {
Session session = HbFactory.getSession();
Transaction t=session.beginTransaction();
Query query = session
.getNamedQuery(querypath);
for (Object obj : args) {
query.setParameter(i, obj);
i++;
}
list = query.list();
t.commit();
}catch(RuntimeException e){
log.error(e);
throw new BussinessException(e);
} finally {
HbFactory.closeSession();
}
return list;
}
* 带参数查询
* @param querypath sql语句路径
* @param args 参数--查询条件
* @return result
* @throws BussinessException
*/
public List queryparam(String querypath,Object...args) throws BussinessException {
List list;
int i = 0;
try {
Session session = HbFactory.getSession();
Transaction t=session.beginTransaction();
Query query = session
.getNamedQuery(querypath);
for (Object obj : args) {
query.setParameter(i, obj);
i++;
}
list = query.list();
t.commit();
}catch(RuntimeException e){
log.error(e);
throw new BussinessException(e);
} finally {
HbFactory.closeSession();
}
return list;
}