1个回答
展开全部
@SuppressWarnings("unchecked")
public List find(Class entityClazz, String sql) {
Session session = getHibernateTemplate().getSessionFactory()
.getCurrentSession();
Transaction transaction = null;
transaction = session.beginTransaction();
try {
SQLQuery result = session.createSQLQuery(sql);
result.addEntity(entityClazz);
return result.list();
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
transaction.commit();
}
}
public List find(Class entityClazz, String sql) {
Session session = getHibernateTemplate().getSessionFactory()
.getCurrentSession();
Transaction transaction = null;
transaction = session.beginTransaction();
try {
SQLQuery result = session.createSQLQuery(sql);
result.addEntity(entityClazz);
return result.list();
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
transaction.commit();
}
}
参考资料: sername
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询