title: Is it possible to turn off hibernate version increment for particular update?
body: <p>Is it possible update entity in database without modifying version of entity using hibernate?</p>
  
  <p>Using my web application users can create or update entities. And where is another asynchronous process which “processes” these entities after any user operation. If user opens entity for update before entity is “processed”, but tries to save it after it is “processed”, user will get “OptimisticLockException” and all his entered data will be lost. But I would like to overwrite data updated in asynchronous process with user provided data.</p>
  
  <p>code snipet to demonstrate why I need such behaviour (JPA + Hibernate):</p>
  
  <pre><code>//user creates entity by filling form in web application
  Entity entity = new Entity ();
  entity.setValue("some value");
  entity.setProcessed (false);
  em.persist(entity);
  em.flush();
  em.clear();
  
  //but after short period of time user changes his mind and again opens entity for update
  entity = em.find(Entity.class, entity.getId());
  em.clear(); //em.clear just for test purposes
  
  //another application asynchronously updates entities 
  List entities = em.createQuery(
                  "select e from Entity e where e.processed = false")
                  .getResultList();
  for (Object o: entities){
      Entity entityDb = (Entity)o;
      someTimeConsumingProcessingOfEntityFields(entityDb); //update lots of diferent entity fields
      entityDb.setProcessed(true);
      em.persist(entityDb);
  }        
  em.flush(); //version of all processed entities are incremented.       
  //Is it possible to prevent version increment?
  em.clear();  
  
  //user modifies entity in web application and again press "save" button
  em.merge(entity); //em.merge just for test purposes
  entity.setValue("some other value");
  entity.setProcessed (false);
  em.persist(entityDb);
  em.flush(); //OptimisticLockException will occur.        
  //Is it possible to prevent this exception from happening?
  //I would like to overwrite data updated in asynchronous process 
  //with user provided data.
  </code></pre>
  
  <p>And my entity:</p>
  
  <pre><code>@Entity
  @Table(name = "enities")
  public class Entity implements Serializable {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
      @Version
      private int versionNum;
      @Column
      private String value
      @Column
      private boolean processed;
      //… and so on (lots other properties)
  }
  </code></pre>
  
  <p>In reality I have much more classes with similar problem - so I am looking for some elegant <strong>non intrusive</strong> solution.</p>
  
  <p>It seems to me this is quite usual scenario. But I could not find any information how to achieve such functionality.</p>