title: check if an email in my database while sign up, using hibernate
body: <p>I am programming an IHM for sign up the users, I need to check if this user is already in database(mysql), checking by his email . can you help me please.
  I can save my user now but how to check if this user by his email</p>
  
  <p>this is my Dao layer class :</p>
  
  <pre><code>public class UserDaoMysql implements UserDao {
  
      private Session session;
  
  
      private void openSession(){
          SessionFactory sessionFactory=HibernateUtil.getSessionFactory();
          session = sessionFactory.openSession();
          session.beginTransaction();
      }
  
      private void closeSession(){
          session.getTransaction().commit();
          session.close();
      }
  
      public void insert(User user) {
  
          if(checkEmail(user)){
  
          openSession();
          User p = new User(user.getName(), user.getEmail(), user.getPassword());
          session.save(p);
          System.out.println("sauvegarde reussi");
          closeSession();
  
          }
  
  
  
      }
  
      public boolean checkEmail(User user){
  
  
          return true;
      }
  
  }
  </code></pre>
  
  <p>this is my user bean :</p>
  
  <pre><code>@ManagedBean(name="user")
  public class User {
  
      private int id;
      private String name;
      private String email;
      private String password;
      private String confirmationPass;
  //  private image 
  
  
      public User() {
          super();
      }
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
  
      public String getConfirmationPass() {
          return confirmationPass;
      }
  
      public void setConfirmationPass(String confirmationPass) {
          this.confirmationPass = confirmationPass;
      }
  
  
      public User(int id, String name, String email, String password,
              String confirmationPass) {
          super();
          this.id = id;
          this.name = name;
          this.email = email;
          this.password = password;
          this.confirmationPass = confirmationPass;
      }
  
      public User(int id, String name, String email, String password) {
          super();
          this.id = id;
          this.name = name;
          this.email = email;
          this.password = password;
      }
  
      public User(String name, String email, String password) {
          super();
          this.name = name;
          this.email = email;
          this.password = password;
      }
  
      @Override
      public String toString() {
          return "User [id=" + id + ", Name=" + name + ", email=" + email
                  + ", password=" + password + "]";
      }
  
      public void save(){
  
  
          UserBusiness userBusiness = new UserBusinessImp();
          userBusiness.add(new User(name, email,password));
  
      }
  
  }
  </code></pre>
  
  <p>And I have a table user in my database.</p>
  
  <p>thanks for your help in advance</p>