Exemplo n.º 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;
 }
Exemplo n.º 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;
  }