1、
final String Hql = String.format(" select e from CancelUser e where e.fileServer.ip= '%1$s'", fileServerIp);
List<CancelUser> result = (List<CancelUser>) getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
Query query = s.createQuery(Hql);
query.setFirstResult(0);
query.setMaxResults(200);
return query.list();
}
});
2、 String sql = "delete from canceluser where fileserveruid=? ";
final String finalSql = sql;
final String finalFileServerUid = fileServerUid;
getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
Query query = s.createSQLQuery(finalSql);
query.setParameter(0, finalFileServerUid);
return query.executeUpdate();
}
});
3、String hql = "from CancelUser c where c.fileServer.ip=?";
return getHibernateTemplate().find(hql,fileServerIp);
4、 String eids = formateUids(ids);
String hql = " delete SellProduct e " +
" where not exists (" +
" select sp.uid from SellDeliveryProduct sp where sp.sellProduct.uid= e.uid " +
" ) and e.uid in(%1$s) ";
return String.format(hql, eids);
protected String formateUids(Serializable... ids) {
String eids = "";
for (int i = 0; i < ids.length; i++) {
eids = eids + "'" + ids[i] + "',";
}
eids = eids.substring(0, eids.length() - 1);
return eids;
}
final String Hql = String.format(" select e from CancelUser e where e.fileServer.ip= '%1$s'", fileServerIp);
List<CancelUser> result = (List<CancelUser>) getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
Query query = s.createQuery(Hql);
query.setFirstResult(0);
query.setMaxResults(200);
return query.list();
}
});
2、 String sql = "delete from canceluser where fileserveruid=? ";
final String finalSql = sql;
final String finalFileServerUid = fileServerUid;
getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
Query query = s.createSQLQuery(finalSql);
query.setParameter(0, finalFileServerUid);
return query.executeUpdate();
}
});
3、String hql = "from CancelUser c where c.fileServer.ip=?";
return getHibernateTemplate().find(hql,fileServerIp);
4、 String eids = formateUids(ids);
String hql = " delete SellProduct e " +
" where not exists (" +
" select sp.uid from SellDeliveryProduct sp where sp.sellProduct.uid= e.uid " +
" ) and e.uid in(%1$s) ";
return String.format(hql, eids);
protected String formateUids(Serializable... ids) {
String eids = "";
for (int i = 0; i < ids.length; i++) {
eids = eids + "'" + ids[i] + "',";
}
eids = eids.substring(0, eids.length() - 1);
return eids;
}