Home > Database > Mysql Tutorial > HQL实现新闻上一篇下一篇

HQL实现新闻上一篇下一篇

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 16:12:56
Original
946 people have browsed it

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);<pre name="code" class="java">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;}}

Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template