title: jpa 2 hibernate setting a lock on EntityManager.find
body: <p>I'm doing a few testcases on an hibernate project:</p>
  
  <p>when I call </p>
  
  <pre><code>EntityManager em = getEntityManager();
  em.find(Foo.class, 1)
  </code></pre>
  
  <p>I get the entity as I expect, but when I invoke:</p>
  
  <pre><code>EntityManager em = getEntityManager();
  em.find(Foo.class, 1, LockModeType.WRITE)
  </code></pre>
  
  <p>I'm getting null. Also, when I make:</p>
  
  <pre><code>EntityManager em = getEntityManager();
  Foo foo = em.find(Foo.class, 1)
  em.lock(foo, LockModeType.WRITE);
  </code></pre>
  
  <p>I'm getting the object, and it's working as I expect.</p>
  
  <p>EDIT:</p>
  
  <pre><code>@javax.persistence.Entity
  @Table(name="foo")
  static class Foo implements Serializable {
      @Id private Integer id;
      private String code;
      @Version private Integer version;
  
      public Foo() {
      }
              ........        
  }
  </code></pre>
  
  <p>My dependencies:</p>
  
  <pre><code>&lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
          &lt;version&gt;3.5.5-Final&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
          &lt;version&gt;4.1.0.Final&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
          &lt;version&gt;3.5.0-Beta-2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;jboss&lt;/groupId&gt;
          &lt;artifactId&gt;jboss&lt;/artifactId&gt;
          &lt;version&gt;4.2.3.GA&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>Can you give me a point?</p>