title: How to query with email id using Hibernate using Session.get()?
body: <p>I am just getting started with Hibernate. And I'm building a sample application where I'm signing up users by their email address. </p>
  
  <p>And when they log in, they use that email address and password. Now, how do I get/retrieve a record/result while querying with their email ids?</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>    Configuration config = new Configuration();
      SessionFactory sessionFactory = config.configure().buildSessionFactory();
      Session session = sessionFactory.openSession();
  
      try{
          Transaction tx = session.beginTransaction();
          LoginBean L = (LoginBean)session.get(LoginBean.class,loginBean.getEmail());
  
      }catch(HibernateException HE){
          System.out.println(HE.getMessage());
      }
  </code></pre>
  
  <p>Of course the <code>email</code> field is a <code>String</code>. And <code>Session.get()</code> takes <code>class,integer</code> as its arguments. I do have a primary key of type <code>Integer</code> but I'd like to do a search/get using the <code>email</code> field. </p>
  
  <p>How do I go about it?</p>