title: OptimisticLockException Ebean even with @Version
body: <p>I tried to update a row in my DB using <code>Ebean</code> in my <code>Play! Framework</code> program. <br/>
  Here is the class of the entity I would like to update. <br> <br>
  <strong>Transaction.java</strong></p>
  
  <pre><code>@Entity
  @Table(name = "transactions")
  public class Transaction extends Model{
  
      @Id
      @GeneratedValue
      public int id; 
      @OneToOne
      @JoinColumn(name = "car_fk")
      public Car car; 
      @OneToOne
      @JoinColumn(name = "user_lender_fk")
      public User user; 
      @Version
      public Timestamp from_date; 
      @Version                    
      public Timestamp to_date;  
      public boolean availability; // true -&gt; Available. 
      public String status; 
  }
  </code></pre>
  
  <p>And here is the metho I use to update it:</p>
  
  <pre><code>Transaction transaction = new Transaction(); 
  transaction.car = concernedCars.get(i); 
  transaction.user = currentUser; 
  transaction.from_date = Tools.StringAndroidToTimestamp(dateFrom); 
  transaction.to_date = Tools.StringAndroidToTimestamp(dateTo); 
  transaction.status = Constants.WAITING_FOR_ANSWER; 
  try{
      Ebean.update(transaction); 
  }catch(OptimisticLockException e){
      Logger.info(e.toString());
  }
  </code></pre>
  
  <p>And if necessary, my method to convert a <em><code>String</code> to <code>Timestamp</code></em>:</p>
  
  <pre><code>public static Timestamp StringAndroidToTimestamp(String s){
          String toConvert = s.substring(0, s.length()-2); 
          Logger.info("ToConvert = "+toConvert);
          Timestamp timestamp = null; 
          try{
              SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
              Date parsedDate = dateFormat.parse(toConvert);
              timestamp = new Timestamp(parsedDate.getTime());
          }catch(Exception e){
              Logger.info("Exception date = " +e.toString());
          }
          return timestamp;
      }
  </code></pre>
  
  <p>Of course, I get the fabulous error:</p>
  
  <blockquote>
    <p>javax.persistence.OptimisticLockException: Data has changed. updated
    [0] rows sql</p>
  </blockquote>
  
  <p>What did I do wrong? </p>