title: Hibernate model class and helper method best practices
body: <p>Please consider the following (partial) class:</p>
  
  <pre><code>@Entity
  @Table(name = "account", catalog = "storeman", uniqueConstraints = @UniqueConstraint(columnNames = "email"))
  public class Account implements java.io.Serializable {
  
      private Integer id;
      private String email;
      private String displayName;
  
      ...
  
      @Id
      @GeneratedValue(strategy = IDENTITY)
      @Column(name = "id", unique = true, nullable = false)
      public Integer getId() {
          return this.id;
      }
  
      @Column(name = "email", unique = true, nullable = false, length = 80)
      public String getEmail() {
          return this.email;
      }
  
      @Column(name = "display_name", nullable = false, length = 50)
      public String getDisplayName() {
          return this.displayName;
      }
  
      public static Account lookup(String email, Session session){
          return (Account)
                  session.createCriteria(Account.class)
                  .add(Restrictions.eq("email", email))
                  .uniqueResult();
      }
  }
  </code></pre>
  
  <p>As you can see, it maps the <code>account</code> table of mydb that uses <code>id</code> as the primary key. However, when searching for Account in db I want use the email as selection criteria. To do so I have added a static method named <code>lookup</code> that performs my query. That works fine as far as I can see.
  However I would like to ask whether that kind of approach is good practice  when working with hibernate (dynamic web project using JDBC) or not and what kind of issues this can bring (if any).</p>