执行sql:
Session session = getSession();
session.createQuery(sql).executeUpdate();
session.flush();
批量执行sql:
Connection conn = SessionFactoryUtils.getDataSource(sessionFacyory).getConnection();
Statement statement = conn.createStatement();
for(String sql : sqls){
statement.addBatch(sql);
}
statement.executeBatch();
statement.close();
执行hsql:
getSession.createQuery(hsql).list();
getSession.createQuery(hsql).uniqueResult();
批量保存:
Session session = getSession();
sesison.setFlushMode(FlushMode.AUTO);
for(Object o : list){
session.save(o);
}
session.flush();
原生态sql进行查询:
getSession().createSQLQuery(sql).list();