epai--E拍项目+oracle数据库建库脚本

  • n0_576111
    了解作者
  • 318.5KB
    文件大小
  • 7z
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-15 07:28
    上传日期
超过20M没有带上jar包,请记得添加jar包,(hibernate3.2+spring2.x+struts1.2+dwr)代码编写很清晰,注释很详细。相信会给大家做项目带来不错参考。
epaiForMe.7z
内容介绍
package y2ssh.ldq.dao.impl; import java.io.Serializable; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.hibernate.Criteria; import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.criterion.Restrictions; import org.springframework.orm.hibernate3.HibernateCallback; import org.springframework.orm.hibernate3.HibernateTemplate; import y2ssh.ldq.dao.BaseDao; import y2ssh.ldq.dao.UserDao; import y2ssh.ldq.entity.Users; public class UserDaoImpl extends BaseDao implements UserDao { HibernateTemplate template = null; public void setSessionFactory(SessionFactory s) { template = new HibernateTemplate(s); } /** * 增加用户 */ public void add(Users item) { /*String sql="insert into epai.users(user_id,user_name,user_password,user_id_code,user_tel,user_addr,user_zip,user_status)" + "values(epai.user_seq.nextval,?,?,?,?,?,?,default)"; openConnection(); try { pstmt = conn.prepareStatement(sql); pstmt.setString(1, item.getUserName()); pstmt.setString(2, item.getUserPassword()); pstmt.setString(3, item.getUserIdCode()); pstmt.setString(4, item.getUserTel()); pstmt.setString(5, item.getUserAddr()); pstmt.setString(6, item.getUserZip()); pstmt.execute(); } catch (SQLException e) { e.printStackTrace(); }finally{ closeAll(); }*/ template.save(item); } public void del(Integer id) { // TODO Auto-generated method stub } /** * 根据条件查询用户(condition final) */ public List<Users> search(final Users condition) { List<Users> userList = new ArrayList<Users>(); /*Users u = null; String sql="select * from epai.users where 1=1 "; if (condition!=null) { if ( condition.getUserId() !=0) { sql +=" and user_id= "+condition.getUserId(); } if (condition.getUserName() !=null && !condition.getUserName().equals("")) { sql +=" and user_name ="+"'"+condition.getUserName()+"'"; } if (condition.getUserPassword() !=null && !condition.getUserPassword().equals("")) { sql +=" and user_password="+"'"+condition.getUserPassword()+"'"; } } openConnection(); try { pstmt = conn.prepareStatement(sql); rs = pstmt.executeQuery(); while(rs.next()){ u = new Users(); u.setUserAddr(rs.getString("user_Addr")); u.setUserId(rs.getInt("user_Id")); u.setUserIdCode(rs.getString("user_Id_Code")); u.setUserName(rs.getString("user_Name")); u.setUserPassword(rs.getString("user_Password")); u.setUserStatus(rs.getInt("user_Status")); u.setUserTel(rs.getString("user_Tel")); u.setUserZip(rs.getString("user_Zip")); userList.add(u); } } catch (SQLException e) { e.printStackTrace(); }finally{ closeAll(); }*/ userList = template.executeFind(new HibernateCallback(){ //实现的查询方法 public Object doInHibernate(Session s) throws HibernateException, SQLException { Criteria c = s.createCriteria(Users.class); if (null != condition) { //用户ID if ( condition.getUserId() !=0) { c.add(Restrictions.eq("userId", condition.getUserId())); } //用户名 if (condition.getUserName() !=null && !condition.getUserName().equals("")) { c.add(Restrictions.eq("userName", condition.getUserName())); } //密码 if (condition.getUserPassword() !=null && !condition.getUserPassword().equals("")) { c.add(Restrictions.eq("userPassword", condition.getUserPassword())); } } return c.list(); } }); return userList; } public void update(Users item) { // TODO Auto-generated method stub } /** * 根据ID 得到用户 */ public Users getUsers(Serializable key) { return (Users)template.get(Users.class, key); } }
评论
    相关推荐