1、Hibernate里使用自定义查询SQL
public List<Qcra> sQcra02(String qcra01) {
String sql = "SELECT * FROM qcra WHERE qcra01 = ?";
SQLQuery sqlQuery = getSession().createSQLQuery(sql);
sqlQuery.setParameter(0, qcra01);
sqlQuery.addEntity(Qcra.class);
List<Qcra> list = sqlQuery.list();
return list;
}
2、Hibernate里使用自定义修改SQL
public void updateQsme02(String newQsme02, String qsme01) {
String hsql = "update qsme set qsme02 = ? where qsme01 = ?";
SQLQuery query = getSession().createSQLQuery(hsql);
query.setParameter(0, newQsme02);
query.setParameter(1, qsme01);
query.executeUpdate();
}