/** * 方法<code>setState</code> 设置登录状态 * * @param id * @param state * @return boolean */ public boolean setState(String id, Boolean state) { /** 通过专家id查询专家对象* */ ExpeRegi expe = getExpeinfoById(id); if (expe == null) return false; /** 如果专家对象非空则设置专家状态* */ Session session = HibernateSessionFactory.getSession(); org.hibernate.Transaction tx = session.beginTransaction(); expe.setState(state); session.update(expe); tx.commit(); // 提交事务。 session.close(); return true; }
public boolean regiExpe( String username, String realname, String password, Boolean sex, String id_card_numb, String email, String phone, String telephone, String referrer) { ExpeRegi obj = getExpeinfoById(username); if (obj != null) return false; // 判断数据库中是否已经存在,若存在则返回false Session session = HibernateSessionFactory.getSession(); org.hibernate.Transaction tx = session.beginTransaction(); obj = new ExpeRegi( username, realname, password, sex, id_card_numb, email, phone, telephone, referrer); session.save(obj); // 保存对象到数据库 tx.commit(); // 提交事务。 session.close(); return true; }