Exemple #1
0
 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;
 }
Exemple #2
0
  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;
  }