整理2
来源:互联网 发布:广西华蓝设计院知乎 编辑:程序博客网 时间:2024/04/28 22:35
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;
}
- 整理2
- 整理2
- JavaScript常见问题整理(2)
- 数据结构代码整理(2)
- Oracle优化整理2
- 整理日志2
- Dozer使用 整理2
- Ocaml 入门整理2
- perl学习整理2
- struts 2 标签整理
- JNI整理(2)
- 2 -- sat 整理
- SharePoint 2007 整理 2
- 功能函数整理(2)
- spring整理2
- dom 整理2
- 学习网站整理2
- 整理项目2
- RAM,ROM,FLASH存储器区别
- Asp.Net+Jquery.Ajax详解3-$.get和$.post
- C#非WEb前端页获取Request 和Server
- 批处理命令大全 / cmd命令大全
- 部分C库函数重写以及反汇编分析之memset()
- 整理2
- Spring的IOC原理[通俗解释一下]
- Android Log分析教程及例子!
- web 网页 表头排序功能
- ajax post提交数据, input type=submit 返回prompt aborted by user .
- Ubuntu 12.04安装Gnome Shell 3
- toad for oralcle 界面设置-显示sql行数
- 构建高可用Linux服务器-第2版
- Window XP驱动开发(二十一) 过滤驱动程序