作者在 2010-04-17 11:03:36 发布以下内容
package com.dao.impl;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.dao.UserDao;
import com.po.Useres;
import com.po.Useres;
public class UserDaoImpl extends HibernateDaoSupport implements UserDao{
注释假如缺少了HibernateDaoSupport报错时就会显示缺少SET方法,HibernateDaoSupport中提供了很多的SPING对HIBERNATE的支持
@SuppressWarnings("unchecked")
public Useres checkUser(String name,String pwd){
String hql="from Useres u where u.username=? and u.password=?";
String para[]=new String[2];
para[0]=name;
para[1]=pwd;
List<Useres> lst=this.getHibernateTemplate().find(hql,para);
if(lst.size()>0)
return (Useres)lst.get(0);
else
return null;
}
public Useres findByName(String name){
String hql="from Useres u where u.username=? ";
List<Useres> lst=this.getHibernateTemplate().find(hql, name);
if(lst.size()>0)
return (Useres)lst.get(0);
else
return null;
}
public Useres saveUser(Useres u){
this.getHibernateTemplate().save(u);
return u;
}
}
@SuppressWarnings("unchecked")
public Useres checkUser(String name,String pwd){
String hql="from Useres u where u.username=? and u.password=?";
String para[]=new String[2];
para[0]=name;
para[1]=pwd;
List<Useres> lst=this.getHibernateTemplate().find(hql,para);
if(lst.size()>0)
return (Useres)lst.get(0);
else
return null;
}
public Useres findByName(String name){
String hql="from Useres u where u.username=? ";
List<Useres> lst=this.getHibernateTemplate().find(hql, name);
if(lst.size()>0)
return (Useres)lst.get(0);
else
return null;
}
public Useres saveUser(Useres u){
this.getHibernateTemplate().save(u);
return u;
}
}