title: Is Hibernate's session thread safe?
body: <p>I need to know, whether the Hibernate's session is thread safe or not. But obvious a new session is attached to every thread for execution. But my question is if in one thread I have updated some value of an entity, so will that be reflected in other thread during same time execution?</p>
  
  <p>My problem is when I fire update from two threads sequentially, the value is updated properly but when I fire the update almost altogether then it fails. </p>
  
  <p>for eg.
  current stage of table.</p>
  
  <pre><code>  ID      NAME      MARKS
  ------- --------- --------
    1       John       54
  </code></pre>
  
  <p>I am trying to do follwing :</p>
  
  <pre><code>Student student = session.load(Student.class, 1);
  student.setMarks(student.getMarks() + 1);
  session.update(student);
  session.close();
  </code></pre>
  
  <p>When I try to run the above code in loop say 10, then value of "marks" in table "student" is properly updated i.e. the value gets updated to 64 which is proper.</p>
  
  <p>But when I try to run the same code in threaded environment, it gives bad results.</p>