⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 peopledao.java

📁 Struts+Hibernate实现软件缺陷的跟踪管理
💻 JAVA
字号:
package xing.five.daos;

import java.util.Iterator;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

import xing.five.beans.BaseHibernateDAO;
import xing.five.beans.HibernateSessionFactory;
import xing.five.beans.PeopleInf;

public class PeopleDao extends BaseHibernateDAO  {
	public boolean check(PeopleInf p)
	{   
	   Boolean   b =   new   Boolean(false);   
		Session session=HibernateSessionFactory.getSession();
		Transaction tx=session.beginTransaction();
		String hql="from xing.five.beans.PeopleInf";
		Query q=session.createQuery(hql);
		tx.commit();
		List l=q.list(); 
		Iterator it= l.iterator();
		while (it.hasNext()){
			PeopleInf people=(PeopleInf)it.next();
	        if(people.getName().equals(p.getName())&&people.getPassword().equals(p.getPassword()))
	        	{b=true;
	        	 break;
	        	}
	        else
	        	b=false;
		}
		return b;
	}
 public Integer getpeopleid(PeopleInf p)
 {
	    Integer id=new Integer(0);
		Session session=HibernateSessionFactory.getSession();
		Transaction tx=session.beginTransaction();
		String hql="from xing.five.beans.PeopleInf";
		Query q=session.createQuery(hql);
		tx.commit();
		List l=q.list(); 
		Iterator it= l.iterator();
		while (it.hasNext()){
			PeopleInf people=(PeopleInf)it.next();
	        if(people.getName().equals(p.getName())&&people.getPassword().equals(p.getPassword()))
	        	id=people.getId();
		}
	        return id;
 }
 
 public String getpeoplename(PeopleInf p)
 {
	    String name=new String();
		Session session=HibernateSessionFactory.getSession();
		Transaction tx=session.beginTransaction();
		String hql="from xing.five.beans.PeopleInf";
		Query q=session.createQuery(hql);
		tx.commit();
		List l=q.list(); 
		Iterator it= l.iterator();
		while (it.hasNext()){
			PeopleInf people=(PeopleInf)it.next();
	        if(people.getName().equals(p.getName())&&people.getPassword().equals(p.getPassword()))
	        	name=people.getName();
		}
	        return name;
 }
 public void update(String password,Integer id)
 {
	    Session session=HibernateSessionFactory.getSession();
		Transaction tx=session.beginTransaction();
		String hql="update xing.five.beans.PeopleInf set password=? where id=?";
		Query q=session.createQuery(hql);
		q.setParameter(0, password);
		q.setParameter(1, id);
		q.executeUpdate();
		tx.commit();
		session.close();
		
 }

 
 public void addpeople(PeopleInf p)
	{
		Session session=HibernateSessionFactory.getSession();
		Transaction tx=session.beginTransaction();
		session.save(p);
		tx.commit();
		session.close();
	}
 
 public Integer getpeopleqx(PeopleInf p)
 {
	    Integer id=new Integer(0);
		Session session=HibernateSessionFactory.getSession();
		Transaction tx=session.beginTransaction();
		String hql="from xing.five.beans.PeopleInf";
		Query q=session.createQuery(hql);
		tx.commit();
		List l=q.list(); 
		Iterator it= l.iterator();
		while (it.hasNext()){
			PeopleInf people=(PeopleInf)it.next();
	        if(people.getName().equals(p.getName())&&people.getPassword().equals(p.getPassword()))
	        	id=people.getQxian();
		}
	        return id;
 }
	public List findConf(String state,String value1) {
       //log.debug("finding WorkInf instance with property: " );

		try {
        	
           String queryString = "from PeopleInf  where name=? or state=? " ;
           Query queryObject = getSession().createQuery(queryString);
           queryObject.setParameter(0, state);
           queryObject.setParameter(1, value1);
  		 return queryObject.list();
        } catch (RuntimeException re) {
          // log.error("find by property name failed", re);
           throw re;
        }
        
        
  	}
	public List querybynameorid(String name,String type)
	{
		Session session=HibernateSessionFactory.getSession();
		Transaction tx=session.beginTransaction();
		String hql="from xing.five.beans.PeopleInf where name=? or type=?";
		Query q=session.createQuery(hql);
		q.setParameter(0, name);
		q.setParameter(1, type);
		tx.commit();
		List l=q.list();
		//Iterator iter=l.iterator();
		//Iterator iter=l.iterator();
		return l;
	}
	
	public List queryall()
	{
		Session session=HibernateSessionFactory.getSession();
		Transaction tx=session.beginTransaction();
		String hql="from xing.five.beans.PeopleInf ";
		Query q=session.createQuery(hql);
		tx.commit();
		List l=q.list();
		//Iterator iter=l.iterator();
		//Iterator iter=l.iterator();
		return l;
	}
	
	public PeopleInf querybyid(Integer id)
	{
		Session session=HibernateSessionFactory.getSession();
		Transaction tx=session.beginTransaction();
		String hql="from xing.five.beans.PeopleInf where id=?";
		Query q=session.createQuery(hql);
		q.setParameter(0, id);
		tx.commit();
		List l=q.list();
		//Iterator iter=l.iterator();
		//Iterator iter=l.iterator();
		return (PeopleInf)l.get(0);
	}
	 public void update(PeopleInf p)
	 {
		    Session session=HibernateSessionFactory.getSession();
			Transaction tx=session.beginTransaction();
			String hql="update xing.five.beans.PeopleInf";
			Query q=session.createQuery(hql);
			q.executeUpdate();
			tx.commit();
			session.close();
			
	 }
	 public void updateqxian(Integer password,Integer id)
	 {
		    Session session=HibernateSessionFactory.getSession();
			Transaction tx=session.beginTransaction();
			String hql="update xing.five.beans.PeopleInf set qxian=? where id=?";
			Query q=session.createQuery(hql);
			q.setParameter(0, password);
			q.setParameter(1, id);
			q.executeUpdate();
			tx.commit();
			session.close();
			
	 }
	 public void updateemail(String password,Integer id)
	 {
		    Session session=HibernateSessionFactory.getSession();
			Transaction tx=session.beginTransaction();
			String hql="update xing.five.beans.PeopleInf set email=? where id=?";
			Query q=session.createQuery(hql);
			q.setParameter(0, password);
			q.setParameter(1, id);
			q.executeUpdate();
			tx.commit();
			session.close();
			
	 }
	 public void updateadd(String password,Integer id)
	 {
		    Session session=HibernateSessionFactory.getSession();
			Transaction tx=session.beginTransaction();
			String hql="update xing.five.beans.PeopleInf set address=? where id=?";
			Query q=session.createQuery(hql);
			q.setParameter(0, password);
			q.setParameter(1, id);
			q.executeUpdate();
			tx.commit();
			session.close();
			
	 }
	 public void updatetel(String password,Integer id)
	 {
		    Session session=HibernateSessionFactory.getSession();
			Transaction tx=session.beginTransaction();
			String hql="update xing.five.beans.PeopleInf set tel=? where id=?";
			Query q=session.createQuery(hql);
			q.setParameter(0, password);
			q.setParameter(1, id);
			q.executeUpdate();
			tx.commit();
			session.close();
			
	 }
	 public void updatename(String password,Integer id)
	 {
		    Session session=HibernateSessionFactory.getSession();
			Transaction tx=session.beginTransaction();
			String hql="update xing.five.beans.PeopleInf set name=? where id=?";
			Query q=session.createQuery(hql);
			q.setParameter(0, password);
			q.setParameter(1, id);
			q.executeUpdate();
			tx.commit();
			session.close();
			
	 }
	 public void updatebmen(String password,Integer id)
	 {
		    Session session=HibernateSessionFactory.getSession();
			Transaction tx=session.beginTransaction();
			String hql="update xing.five.beans.PeopleInf set bmen=? where id=?";
			Query q=session.createQuery(hql);
			q.setParameter(0, password);
			q.setParameter(1, id);
			q.executeUpdate();
			tx.commit();
			session.close();
			
	 }
	 public void updatetype(String password,Integer id)
	 {
		    Session session=HibernateSessionFactory.getSession();
			Transaction tx=session.beginTransaction();
			String hql="update xing.five.beans.PeopleInf set type=? where id=?";
			Query q=session.createQuery(hql);
			q.setParameter(0, password);
			q.setParameter(1, id);
			q.executeUpdate();
			tx.commit();
			session.close();
			
	 }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -