欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

HQL实现新闻上一篇下一篇

程序员文章站 2022-05-25 17:46:08
...

daoImpl实现的方法: public News nextPage(News news){try{String queryString=from News d where d.id? order by id desc;Q【本文来自鸿网互联 (http://www.68idc.cn)】uery queryObject=getSession().createQuery(queryString);queryObject.setLong(0,new

daoImpl实现的方法:

public News nextPage(News news){
		try{
			String queryString="from News d where d.id order by id desc";
			Q【本文来自鸿网互联 (http://www.68idc.cn)】uery queryObject=getSession().createQuery(queryString);
			queryObject.setLong(0,news.getId());
			queryObject.setFirstResult(0);
			queryObject.setMaxResults(1);
public News nextPage(News news) {
		try {
			String queryString = "from News d where d.id>? order by id asc";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setLong(0,news.getId());
			queryObject.setFirstResult(0);
			queryObject.setMaxResults(1);
			return (News)queryObject.list().get(0);
		} catch (RuntimeException re) {

			throw re;
		}
		
	}

return (News)queryObject.list().get(0);}catch(RuntimeException re){throw re;}}