- 浏览: 26379 次
- 性别:
- 来自: 武汉
文章分类
最新评论
//数据库表
create table Student
(
stuid varchar(32) primary key,
stuname varchar(32),
stuage int,
stusex char(2),
stuaddr varchar(50)
)
//////////////////////////com.svse.entity///////////////////////////
//Student实体
package com.svse.entity;
public class Student {
private String stuid;
private String stuname;
private int stuage;
private String stusex;
private String stuaddr;
public Student() {
// TODO Auto-generated constructor stub
}
public Student(String stuaddr, int stuage, String stuid, String stuname,
String stusex) {
super();
this.stuaddr = stuaddr;
this.stuage = stuage;
this.stuid = stuid;
this.stuname = stuname;
this.stusex = stusex;
}
public String getStuid() {
return stuid;
}
public void setStuid(String stuid) {
this.stuid = stuid;
}
public String getStuname() {
return stuname;
}
public void setStuname(String stuname) {
this.stuname = stuname;
}
public int getStuage() {
return stuage;
}
public void setStuage(int stuage) {
this.stuage = stuage;
}
public String getStusex() {
return stusex;
}
public void setStusex(String stusex) {
this.stusex = stusex;
}
public String getStuaddr() {
return stuaddr;
}
public void setStuaddr(String stuaddr) {
this.stuaddr = stuaddr;
}
}
//Student.hbm.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class name="com.svse.entity.Student" table="Student">
<id name="stuid" column="stuid" type="string" length="32">
<generator class="assigned"></generator>
</id>
<property name="stuname" column="stuname" type="string" length="32"></property>
<property name="stuage" column="stuage" type="integer"></property>
<property name="stusex" column="stusex" type="string" length="32"></property>
<property name="stuaddr" column="stuaddr" type="string" length="32"></property>
</class>
</hibernate-mapping>
//////////////////////////com.svse.util///////////////////////////
//分页辅助类
package com.svse.util;
public class PageHelp {
int totalcount;//总行数
int linesize;//每页显示的条数
int totalpage;// 总页数
int currentpage;//当前页
public PageHelp() {
// TODO Auto-generated constructor stub
}
public PageHelp(int currentpage, int linesize, int totalcount, int totalpage) {
super();
this.currentpage = currentpage;
this.linesize = linesize;
this.totalcount = totalcount;
this.totalpage = totalpage;
}
public int getTotalcount() {
return totalcount;
}
public void setTotalcount(int totalcount) {
this.totalcount = totalcount;
}
public int getLinesize() {
return linesize;
}
public void setLinesize(int linesize) {
this.linesize = linesize;
}
public int getTotalpage() {
return totalpage;
}
//设置总页数
public void setTotalpage() {
if(this.getTotalcount()%this.getLinesize()==0)
{
this.totalpage = this.getTotalcount()/this.getLinesize();
}
else
{
this.totalpage = this.getTotalcount()/this.getLinesize()+1;
}
}
public int getCurrentpage() {
return currentpage;
}
public void setCurrentpage(int currentpage) {
this.currentpage = currentpage;
}
}
//字符过滤器
package com.svse.util;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class Filter implements javax.servlet.Filter {
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("text/html;charset=utf-8");
chain.doFilter(request, response);
}
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}
}
//SessionFactory类
package com.svse.util;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
public class DefaultSessionFactory {
public static Session getSession()
{
return new Configuration().
configure().buildSessionFactory().openSession();
}
}
/////////////////////////////com.svse.dao/////////////////////////////
//StudentDao类
package com.svse.dao;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import com.svse.entity.Student;
import com.svse.util.DefaultSessionFactory;
public class StudentDao {
private Session session=null;
public StudentDao() {
this.session=DefaultSessionFactory.getSession();
}
//查询所有记录的条数
public long getTotalCount()
{
String hql="select count(stuname) from Student";
Query query=this.session.createQuery(hql);
return (Long)query.uniqueResult();
}
//获取当前分页后的集合
public List<Student> getCurrentList(int currentPage,int lineSize)
{
String hql="from Student";
Query query=this.session.createQuery(hql);
query.setFirstResult((currentPage-1)*lineSize);
query.setMaxResults(lineSize);
return query.list();
}
public List findAll()
{
String hql="from Student";
Query query=this.session.createQuery(hql);
return query.list();
}
}
////////////////////////////com.svse.action///////////////////////////
//StudentAction类
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.svse.struts.action;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.svse.dao.StudentDao;
import com.svse.entity.Student;
import com.svse.util.PageHelp;
/**
* MyEclipse Struts
* Creation date: 06-21-2011
*
* XDoclet definition:
* @struts.action validate="true"
*/
public class StudentAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
private StudentDao studao=new StudentDao();
public ActionForward findAllStu(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
//int totalCount=(int)studao.getTotalCount();
int totalCount=studao.findAll().size();
System.err.println("xxxxxxxxx : "+totalCount);
PageHelp ph=new PageHelp();
ph.setTotalcount(totalCount);
ph.setLinesize(3);
ph.setTotalpage();
int currentPage=0;
if(request.getParameter("currentPage")==null)
{
currentPage=1;
}
else
{
currentPage=Integer.parseInt(request.getParameter("currentPage"));
//防止下标越界的情况
if(currentPage<1)
{
currentPage=1;
}
if(currentPage>ph.getTotalpage())
{
currentPage=ph.getTotalpage();
}
}
ph.setCurrentpage(currentPage);
List<Student> stulist=studao.getCurrentList(ph.getCurrentpage(), ph.getLinesize());
request.setAttribute("stulist", stulist);
request.setAttribute("pagehelp", ph);
System.err.println(stulist.size());
for (Student student : stulist) {
System.err.println(student.getStuname()+student.getStuid());
}
return mapping.findForward("tostulist");
}
}
//显示信息的JSP页面
<%@ page language="java" pageEncoding="utf-8" isELIgnored="false"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
<html:base />
<title>Hibernate分页</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<center>
<table border="0" align="center" width="40%">
<tr align="center" bgcolor="pink">
<td colspan="5">学生详细信息</td>
</tr>
<tr align="center" bgcolor="pink">
<td colspan="5"><hr></td>
</tr>
<tr bgcolor="pink">
<td>编号</td>
<td>姓名</td>
<td>年龄</td>
<td>性别</td>
<td>地址</td>
</tr>
<logic:iterate id="s" name="stulist">
<tr bgcolor="pink">
<td>${s.stuid }</td>
<td>${s.stuname }</td>
<td>${s.stuage}</td>
<td>${s.stusex }</td>
<td>${s.stuaddr }</td>
</tr>
</logic:iterate>
<tr align="center" bgcolor="pink">
<td colspan="5"><hr></td>
</tr>
<tr bgcolor="pink">
<td colspan="5" width="700" align="center">
<a href="student.do?method=findAllStu¤tPage=1"><img src="image/head.gif" style="border: none;"/></a>
<a href="student.do?method=findAllStu¤tPage=${pagehelp.currentpage-1 }"><img src="image/top.gif" style="border: none;"/></a>
<a href="student.do?method=findAllStu¤tPage=${pagehelp.currentpage+1 }"><img src="image/next.gif" style="border: none;"/></a>
<a href="student.do?method=findAllStu¤tPage=${pagehelp.totalpage }"><img src="image/end.gif" style="border: none;"/></a>
</td>
</tr>
<tr align="center" bgcolor="pink">
<td colspan="5">
<font color="red">当前是:【${pagehelp.currentpage}】页, 一共【${pagehelp.totalpage}】页</font>
</td>
</tr>
</table>
</center>
</body>
</html:html>
//Struts-config-xml配置文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans />
<global-exceptions />
<global-forwards />
<action-mappings >
<action path="/student"
type="com.svse.struts.action.StudentAction"
parameter="method"
>
<forward name="tostulist" path="/showstu.jsp"></forward>
</action>
</action-mappings>
<message-resources parameter="com.svse.struts.ApplicationResources" />
</struts-config>
//Hibernate-cfg-xml配置文件
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="connection.username">scott</property>
<property name="connection.url">
jdbc:oracle:thin:@localhost:1521:orcl
</property>
<property name="dialect">
org.hibernate.dialect.Oracle9Dialect
</property>
<property name="myeclipse.connection.profile">oracle</property>
<property name="connection.password">tiger</property>
<property name="connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping resource="com/svse/entity/Student.hbm.xml" />
</session-factory>
</hibernate-configuration>
create table Student
(
stuid varchar(32) primary key,
stuname varchar(32),
stuage int,
stusex char(2),
stuaddr varchar(50)
)
//////////////////////////com.svse.entity///////////////////////////
//Student实体
package com.svse.entity;
public class Student {
private String stuid;
private String stuname;
private int stuage;
private String stusex;
private String stuaddr;
public Student() {
// TODO Auto-generated constructor stub
}
public Student(String stuaddr, int stuage, String stuid, String stuname,
String stusex) {
super();
this.stuaddr = stuaddr;
this.stuage = stuage;
this.stuid = stuid;
this.stuname = stuname;
this.stusex = stusex;
}
public String getStuid() {
return stuid;
}
public void setStuid(String stuid) {
this.stuid = stuid;
}
public String getStuname() {
return stuname;
}
public void setStuname(String stuname) {
this.stuname = stuname;
}
public int getStuage() {
return stuage;
}
public void setStuage(int stuage) {
this.stuage = stuage;
}
public String getStusex() {
return stusex;
}
public void setStusex(String stusex) {
this.stusex = stusex;
}
public String getStuaddr() {
return stuaddr;
}
public void setStuaddr(String stuaddr) {
this.stuaddr = stuaddr;
}
}
//Student.hbm.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class name="com.svse.entity.Student" table="Student">
<id name="stuid" column="stuid" type="string" length="32">
<generator class="assigned"></generator>
</id>
<property name="stuname" column="stuname" type="string" length="32"></property>
<property name="stuage" column="stuage" type="integer"></property>
<property name="stusex" column="stusex" type="string" length="32"></property>
<property name="stuaddr" column="stuaddr" type="string" length="32"></property>
</class>
</hibernate-mapping>
//////////////////////////com.svse.util///////////////////////////
//分页辅助类
package com.svse.util;
public class PageHelp {
int totalcount;//总行数
int linesize;//每页显示的条数
int totalpage;// 总页数
int currentpage;//当前页
public PageHelp() {
// TODO Auto-generated constructor stub
}
public PageHelp(int currentpage, int linesize, int totalcount, int totalpage) {
super();
this.currentpage = currentpage;
this.linesize = linesize;
this.totalcount = totalcount;
this.totalpage = totalpage;
}
public int getTotalcount() {
return totalcount;
}
public void setTotalcount(int totalcount) {
this.totalcount = totalcount;
}
public int getLinesize() {
return linesize;
}
public void setLinesize(int linesize) {
this.linesize = linesize;
}
public int getTotalpage() {
return totalpage;
}
//设置总页数
public void setTotalpage() {
if(this.getTotalcount()%this.getLinesize()==0)
{
this.totalpage = this.getTotalcount()/this.getLinesize();
}
else
{
this.totalpage = this.getTotalcount()/this.getLinesize()+1;
}
}
public int getCurrentpage() {
return currentpage;
}
public void setCurrentpage(int currentpage) {
this.currentpage = currentpage;
}
}
//字符过滤器
package com.svse.util;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class Filter implements javax.servlet.Filter {
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("text/html;charset=utf-8");
chain.doFilter(request, response);
}
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}
}
//SessionFactory类
package com.svse.util;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
public class DefaultSessionFactory {
public static Session getSession()
{
return new Configuration().
configure().buildSessionFactory().openSession();
}
}
/////////////////////////////com.svse.dao/////////////////////////////
//StudentDao类
package com.svse.dao;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import com.svse.entity.Student;
import com.svse.util.DefaultSessionFactory;
public class StudentDao {
private Session session=null;
public StudentDao() {
this.session=DefaultSessionFactory.getSession();
}
//查询所有记录的条数
public long getTotalCount()
{
String hql="select count(stuname) from Student";
Query query=this.session.createQuery(hql);
return (Long)query.uniqueResult();
}
//获取当前分页后的集合
public List<Student> getCurrentList(int currentPage,int lineSize)
{
String hql="from Student";
Query query=this.session.createQuery(hql);
query.setFirstResult((currentPage-1)*lineSize);
query.setMaxResults(lineSize);
return query.list();
}
public List findAll()
{
String hql="from Student";
Query query=this.session.createQuery(hql);
return query.list();
}
}
////////////////////////////com.svse.action///////////////////////////
//StudentAction类
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.svse.struts.action;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.svse.dao.StudentDao;
import com.svse.entity.Student;
import com.svse.util.PageHelp;
/**
* MyEclipse Struts
* Creation date: 06-21-2011
*
* XDoclet definition:
* @struts.action validate="true"
*/
public class StudentAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
private StudentDao studao=new StudentDao();
public ActionForward findAllStu(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
//int totalCount=(int)studao.getTotalCount();
int totalCount=studao.findAll().size();
System.err.println("xxxxxxxxx : "+totalCount);
PageHelp ph=new PageHelp();
ph.setTotalcount(totalCount);
ph.setLinesize(3);
ph.setTotalpage();
int currentPage=0;
if(request.getParameter("currentPage")==null)
{
currentPage=1;
}
else
{
currentPage=Integer.parseInt(request.getParameter("currentPage"));
//防止下标越界的情况
if(currentPage<1)
{
currentPage=1;
}
if(currentPage>ph.getTotalpage())
{
currentPage=ph.getTotalpage();
}
}
ph.setCurrentpage(currentPage);
List<Student> stulist=studao.getCurrentList(ph.getCurrentpage(), ph.getLinesize());
request.setAttribute("stulist", stulist);
request.setAttribute("pagehelp", ph);
System.err.println(stulist.size());
for (Student student : stulist) {
System.err.println(student.getStuname()+student.getStuid());
}
return mapping.findForward("tostulist");
}
}
//显示信息的JSP页面
<%@ page language="java" pageEncoding="utf-8" isELIgnored="false"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
<html:base />
<title>Hibernate分页</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<center>
<table border="0" align="center" width="40%">
<tr align="center" bgcolor="pink">
<td colspan="5">学生详细信息</td>
</tr>
<tr align="center" bgcolor="pink">
<td colspan="5"><hr></td>
</tr>
<tr bgcolor="pink">
<td>编号</td>
<td>姓名</td>
<td>年龄</td>
<td>性别</td>
<td>地址</td>
</tr>
<logic:iterate id="s" name="stulist">
<tr bgcolor="pink">
<td>${s.stuid }</td>
<td>${s.stuname }</td>
<td>${s.stuage}</td>
<td>${s.stusex }</td>
<td>${s.stuaddr }</td>
</tr>
</logic:iterate>
<tr align="center" bgcolor="pink">
<td colspan="5"><hr></td>
</tr>
<tr bgcolor="pink">
<td colspan="5" width="700" align="center">
<a href="student.do?method=findAllStu¤tPage=1"><img src="image/head.gif" style="border: none;"/></a>
<a href="student.do?method=findAllStu¤tPage=${pagehelp.currentpage-1 }"><img src="image/top.gif" style="border: none;"/></a>
<a href="student.do?method=findAllStu¤tPage=${pagehelp.currentpage+1 }"><img src="image/next.gif" style="border: none;"/></a>
<a href="student.do?method=findAllStu¤tPage=${pagehelp.totalpage }"><img src="image/end.gif" style="border: none;"/></a>
</td>
</tr>
<tr align="center" bgcolor="pink">
<td colspan="5">
<font color="red">当前是:【${pagehelp.currentpage}】页, 一共【${pagehelp.totalpage}】页</font>
</td>
</tr>
</table>
</center>
</body>
</html:html>
//Struts-config-xml配置文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans />
<global-exceptions />
<global-forwards />
<action-mappings >
<action path="/student"
type="com.svse.struts.action.StudentAction"
parameter="method"
>
<forward name="tostulist" path="/showstu.jsp"></forward>
</action>
</action-mappings>
<message-resources parameter="com.svse.struts.ApplicationResources" />
</struts-config>
//Hibernate-cfg-xml配置文件
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="connection.username">scott</property>
<property name="connection.url">
jdbc:oracle:thin:@localhost:1521:orcl
</property>
<property name="dialect">
org.hibernate.dialect.Oracle9Dialect
</property>
<property name="myeclipse.connection.profile">oracle</property>
<property name="connection.password">tiger</property>
<property name="connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping resource="com/svse/entity/Student.hbm.xml" />
</session-factory>
</hibernate-configuration>
相关推荐
Hibernate分页查询小结
#### 三、Hibernate分页查询实现原理 ##### 3.1 使用SQL LIMIT实现分页 对于支持LIMIT关键字的数据库(例如MySQL),Hibernate会通过特定的方言(Dialect)来生成包含LIMIT关键字的SQL语句。具体实现如下: ```...
此外,优化查询,避免N+1查询问题,合理设计实体关系,都能有效提升Hibernate分页查询的效率。 总结起来,Hibernate的分页查询和数据库连接管理是其强大功能的重要组成部分。正确理解和使用这些特性,能够帮助...
标题与描述均提到了“Hibernate分页的设计和编码”,这表明文章主要聚焦于如何在Hibernate框架中实现数据分页功能。下面将详细解析这一主题的关键知识点。 ### Hibernate分页概念 Hibernate是Java环境下一个开放源...
让我们深入探讨Hibernate分页查询的相关知识点。 一、Hibernate分页原理 Hibernate分页查询基于SQL的LIMIT和OFFSET子句,通过Session的createQuery或createSQLQuery方法创建查询,并设置FirstResult和MaxResults...
hibernate分页(无排序,搜索,仅仅分页显示),服务器端分页在datatables上展现,有关 datatables的知识请关注它的官网http://www.datatables.net/,datatables的功能很 全面。 2,建表的sql--studentinfo和插入...
总结起来,"hibernate分页代码"是一个关于如何在Hibernate中进行分页查询的实践示例,适用于在MyEclipse环境下运行。通过Criteria API或HQL,开发者能够方便地实现分页功能,提升应用性能,为用户提供更好的体验。...
在"Struts + Hibernate 分页实现"这个项目中,重点在于如何在Web应用中整合这两个框架,并实现数据的分页显示。分页是大型数据集处理时常见的需求,它能够帮助用户更有效地浏览和管理大量信息,避免一次性加载所有...
本篇文章将详细讲解如何在基于Struts2、Spring和Hibernate的项目中实现分页功能。 首先,我们从DAO层开始。在`MemberDao`接口中,我们定义了两个关键的方法,一个是用于分页查询,另一个是获取所有记录的数量。这两...
在"Struts+Hibernate分页及条件查询练习"这个项目中,开发者可能采用了以下步骤: 1. **配置Struts和Hibernate**:首先,需要在项目中引入Struts和Hibernate的相关库,配置Struts的struts-config.xml文件和...
1. **配置Hibernate分页**: 在Hibernate中,我们通常使用`Criteria`或`Query` API进行分页查询。`Criteria`提供了一种更面向对象的方式来执行SQL查询,而`Query` API则对应于原生的SQL语句。在这些API中,我们可以...
hibernate分页 博文链接:https://iomo.iteye.com/blog/243518
本篇主要围绕"Hibernate分页查询效果"这一主题,深入探讨如何利用Hibernate框架实现高效、便捷的分页功能。 首先,Hibernate是一个优秀的Java持久化框架,它提供了ORM(对象关系映射)解决方案,使得开发者可以使用...
**hibernate分页**是Java开发中一个重要的技术概念,特别是在处理大数据量时,为了提高用户体验和系统性能,分页查询是不可或缺的。Hibernate,作为一款强大的对象关系映射(ORM)框架,提供了多种实现分页查询的...
这个"高效率的dw+spring+hibernate分页演示例子"提供了一个实用的示例,展示了如何将这三个框架整合起来,以实现高效的数据分页功能。 首先,让我们来逐一了解这三个技术: 1. **DWR (Direct Web Remoting)**:DWR...
### Hibernate分页基础 1. **Criteria API**:Hibernate的Criteria API允许我们创建动态查询,同时也支持分页。通过设置`setFirstResult()`和`setMaxResults()`方法,可以实现分页效果。例如: ```java Criteria ...
综上所述,"struts+hibernate分页"涉及到的主要是如何在Struts的控制层和Hibernate的数据层之间协调处理分页请求,以及在DAO层利用Hibernate的特性实现数据库查询的分页。理解并掌握这两个框架的分页机制,对于开发...
java 实现的一个简单的hibernate分页类 可以设置,从某一条开始取、显示的条数 不依赖struts spring
本教程将通过一个具体的“hibernate分页例子”来深入理解如何在Hibernate中实现分页功能。 在实际应用中,当数据量大到一定程度时,一次性加载所有数据会导致内存压力过大,影响系统性能。因此,分页查询成为一种...
本主题将探讨如何在Hibernate分页类和JDBC的SQL分页方法之间实现完美的融合,以提高性能并提供更好的用户体验。 首先,让我们了解一下Hibernate的分页功能。Hibernate提供了一种方便的方式来处理分页查询,通过...