title: EntityNotFoundException in Hibernate Many To One mapping however data exist
body: <p>I'm getting an error</p>
  
  <blockquote>
    <p>Caused by: javax.persistence.EntityNotFoundException: Unable to find tn.entities.AgenceBnq with id 01 </p>
  </blockquote>
  
  <p>when I get AgenceBnq through Employee</p>
  
  <p><code>Employee</code> class:</p>
  
  <pre><code>@Table(name = "EMPLOYEE")
  @NamedQuery(name = "Employee.findById", query = "SELECT e FROM Employee e WHERE e.employeMat = ?1"),
  
  public class Employee implements Serializable {
  private static final long serialVersionUID = 1L;
  
  @Id
  @Column(name = "EMPLOYEE_MAT", unique = true, nullable = false, length = 15)
  private String employeeMat;
  ...
  @ManyToOne
  @JoinColumn(name = "AGENCE_COD")
  private AgenceBnq agenceBnq;
  }
  
  @Entity
  @Table(name="AGENCEBNQ")
  
  public class AgenceBnq implements Serializable {
  private static final long serialVersionUID = 1L;
  
  @Id
  @Column(name="AGENCE_COD", unique=true, nullable=false, length=10)
  private String agenceCod;
  
  ...
  //bi-directional many-to-one association to Employee
  @OneToMany(mappedBy="agenceBnq")
  private Set&lt;Employee&gt; employees;
  }
  </code></pre>
  
  <p>I'm calling namedQuery Employee.findById in DAO to retrieve data and I have to get AgenceBnq from Employee but get this error while calling <code>query.getResultList()</code></p>
  
  <p><code>@NotFound( action = NotFoundAction.IGNORE)</code> isn't useful for me because data exist in AGENCEBNQ table and I have to retrieve date through <code>Employee</code>.</p>
  
  <p>Is this a bug in hibernate ? I'm using hibernate version 3.6.7.Final</p>