📄 employeetabledao.java
字号:
package com.xfaccp.dao;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import com.xfaccp.adapter.DAOAdpater;
import com.xfaccp.form.EmployeeTable;
/**
* Data access object (DAO) for domain model class EmployeeTable.
*
* @see com.xfaccp.form.EmployeeTable
* @author MyEclipse Persistence Tools
*/
public class EmployeeTableDAO extends DAOAdpater {
public List findAllList() throws Exception {
System.out.println("findAllList!!!!!!!!!!!!!");
return getHibernateTemplate().find("from com.xfaccp.form.EmployeeTable");
}
public List findById(Integer id)
throws Exception {
System.out.println("this is the daomethod!!!!!!!!!");
String hql = "from com.xfaccp.form.EmployeeTable where id="+id;
List list = getHibernateTemplate().find(hql);
return list;
}
// 用户登陆时根据用户名和密码查询用户的权限
public List checkLogin(String useName,String pwd)throws Exception
{
List list=new ArrayList();
String hql="from EmployeeTable where userName=? and pwd=?";
//将参数保存到一数组中
Object[] obj = {useName,pwd};
//用List保存查询的信息
list=getHibernateTemplate().find(hql,obj);
return list;
}
public List findBySqlto(String hsql,Object [] obj)throws Exception
{
List list = null;
EmployeeTable emp = (EmployeeTable) obj[0];
//System.out.println(">>>>>>>>>>>>>>>>>>> "+emp.getEmpName());
if(emp.getEmpName() != null && !"".equals(emp.getEmpName()))
{
hsql += "and empName like ?";
list = getHibernateTemplate().find(hsql,"%"+emp.getEmpName()+"%");
}else
list = getHibernateTemplate().find(hsql);
/*DetachedCriteria dc = DetachedCriteria.forClass(emp.getClass());
dc.add(Restrictions.like("empName", emp.getEmpName()));
list = getHibernateTemplate().findByCriteria(dc);*/
return list;
}
//获取表中所有记录
public List getEmployeeTableList(int size, int pageSize) throws Exception {
List list;
Session session = getSession();
try {
Query q = session.createQuery("from com.xfaccp.form.EmployeeTable");
q.setFirstResult(size);
q.setMaxResults(pageSize);
list = q.list();
} finally{
session.close();
}
return list;
}
//设置页数
public int getEmployeeTableSize() throws Exception {
String hql=" select count(*) from com.xfaccp.form.EmployeeTable";
List list=this.getHibernateTemplate().find(hql);
int count=(Integer)list.get(0);
return count;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -