1个回答
展开全部
/*
* 分页取数据,取前几个数据
*pageNo是第几页,pageSize是一页显示多少条
*这是hibernate的dao里面的sql语句
*/
public List findByPage(int pageNo,int pageSize) {
log.debug("finding UserInfo instance with property: " + pageNo
+ ", value: " + pageSize);
try {
String queryString = "from UserInfo" ;
Query queryObject = getSession().createQuery(queryString);
queryObject.setFirstResult((pageNo-1)*pageSize);
queryObject.setMaxResults(pageSize);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
/*
* 分页根据密码,这是给你举个例子,password可以是根据id之类的
*
*/
public List findByPassword(int pageNo,int pageSize,String password) {
log.debug("finding UserInfo instance with property: " + pageNo
+ ", value: " + pageSize);
try {
String queryString = "from UserInfo as u where u.password="+password ;
Query queryObject = getSession().createQuery(queryString);
queryObject.setFirstResult((pageNo-1)*pageSize);
queryObject.setMaxResults(pageSize);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
* 分页取数据,取前几个数据
*pageNo是第几页,pageSize是一页显示多少条
*这是hibernate的dao里面的sql语句
*/
public List findByPage(int pageNo,int pageSize) {
log.debug("finding UserInfo instance with property: " + pageNo
+ ", value: " + pageSize);
try {
String queryString = "from UserInfo" ;
Query queryObject = getSession().createQuery(queryString);
queryObject.setFirstResult((pageNo-1)*pageSize);
queryObject.setMaxResults(pageSize);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
/*
* 分页根据密码,这是给你举个例子,password可以是根据id之类的
*
*/
public List findByPassword(int pageNo,int pageSize,String password) {
log.debug("finding UserInfo instance with property: " + pageNo
+ ", value: " + pageSize);
try {
String queryString = "from UserInfo as u where u.password="+password ;
Query queryObject = getSession().createQuery(queryString);
queryObject.setFirstResult((pageNo-1)*pageSize);
queryObject.setMaxResults(pageSize);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询