备忘是希望自己不要忘记了。以后还可以拿出来玩玩
@Repository
@Transactional
public class CommonDAO extends HibernateBaseDao<Object, Long> {
@SuppressWarnings("rawtypes")
public List queryByQLList(String hql) throws Exception {
List list = new ArrayList();
try {
list = this.find(hql);
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
public void saveEntity(A a) {
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
session.merge(a);
session.flush();
try {
tx.commit();
} catch (Exception e) {
tx.rollback();
e.printStackTrace();
}
session.close();
}
}@Repository
@Trans