Hibernate的获取和删除备份

Hibernate的获取和删除备份

public int delNews(final List arr_id) {
return ( (Integer)this.getHibernateTemplate().execute(
new HibernateCallback() {
public Object doInHibernate(Session session) throws SQLException,
HibernateException {
Query q = session.createQuery(
"delete net.csdn.News where arrid in (:ids)");
q.setParameterList("ids", arr_id);
return new Integer(q.executeUpdate());
}
})).intValue();
}
///
public List getNewsList(final int num) {
return (List) getHibernateTemplate().execute( new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
String hql = "FROM News n1 order by id desc" ;
Query query = session.createQuery( hql );
query.setMaxResults( num ) ;
List list = query.list();
if ( list.size() > 0 ) {
return list;
} else {
return null;
}
}
});
}

时间: 2024-09-16 04:17:57

Hibernate的获取和删除备份的相关文章

javascript实现设置、获取和删除Cookie的方法

  本文实例讲述了javascript实现设置.获取和删除Cookie的方法.分享给大家供大家参考.具体实现方法如下: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66

JS中cookie的编写,获取,删除,急求

问题描述 java语言编写的js中如何编写,获取,删除cookie 解决方案 解决方案二:好像JavaScript应该没有提供这个类来获取,当然删除就不用说了.在servlet里面就可以.在servlet里客户端一发出请求,你可以用以下方法:Cookie[]ck=getCookies();//获取客户端里的cookie,因为浏览器一般不止保存一个Cookie,所以用数组来获取,在进行遍历,遍历一个就判断一个,是不是你所要的Cookie.如果找到是你所要的,就返回一个String类型的key值,再

Hibernate AnnotationSessionFactoryBean 获取sessionFactory问题

问题描述 下面的代码中,getSessionFactory方法中a.getObject()返回的值为null.请问是应该怎么解决啊???@SuppressWarnings("unchecked") @Configuration@Componentpublic class AppConfig implements ServletConfigAware,ServletContextAware{//hibernate(读取配置文件中的值) private @Value("${hib

关于基于Hibernate留言板的疑惑,hibernate自动获取关联对象的问题

问题描述 只有用户,和留言两个表,POJO如下: public class Article {private Integer id;private String title;private String content;private User user; //省略setter,getter}  public class User {private Integer id;private String username;private String password;private Set<Art

jQuery元素属性操作实例(设置、获取及删除元素属性)_jquery

本文实例讲述了jQuery元素属性操作的方法.分享给大家供大家参考,具体如下: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="js/jquery-1.10.1.min.js" type="tex

jquery中cookie用法实例详解(获取,存储,删除等)_jquery

本文实例讲述了jquery中cookie用法.分享给大家供大家参考,具体如下: cookie在jquery中有指定的cookie操作类,下面我先来介绍我们在使用cookie操作类时的一些问题,然后介绍正确的使用方法. 使用JQuery操作cookie时 发生取的值不正确的问题: 结果发现cookie有四个不同的属性: 名称,内容,域,路径 $.cookie('the_cookie'); // 读取 cookie $.cookie('the_cookie', 'the_value'); // 存储

获取添加删除程序列表

问题描述 我查资料说添加删除程序列表在注册表下:HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall64位机在HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall但是我现在发现,有些程序在注册表下该位置有,但在添加删除程序列表里面没有,这是为什么?以什么做判断依据?我怎么才能够通过程序获取列表呢? 解决方案 解决方案二:

javascript js cookie的存储,获取和删除_javascript技巧

使用方法: //1.存储Cookie //2.参数说明: 1.参数1:Cookie存储Name,参数2:Cookie要存储的值 //3.例子如下: setCookie('Method',match); //1.获取Cookie //2.参数说明: 1.参数1:Cookie存储的Name //3.例子如下: getCookie('Method') //1.删除Cookie //2.参数说明: 1.参数1:Cookie存储的Name //3.例子如下: deleteCookie('Method');

hibernate 多对多 级联删除 注解

问题描述 有两个类:Survey和Questions,问卷类和题目类,它们是多对多的关系,即:一张试卷可以有多个题目,一个题目可以属于多个试卷,我用两个一对多,数据库用中间表来实现,并有第三个类SurveyQuestions. surveuy类如下: //问卷实体:包括各种属性@Entity@Table(name="_survey")public class Survey {private int id;// 问卷IDprivate String name;// 问卷标题private