public Visitor save(Visitor Visitor) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); try { session.beginTransaction(); session.save(Visitor); session.getTransaction().commit(); } catch (Exception e) { session.getTransaction().rollback(); } return Visitor; }
public Visitor findVisitor(String username) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); Visitor Visitor = (Visitor) session .createCriteria(Visitor.class) .add(Restrictions.eq("username", username)) .uniqueResult(); return Visitor; }