0

The Vaadin book says I can set a column for optimistic locking as follows:

tq.setVersionColumn("OPTLOCK");

However it also says that:

TableQuery assumes that the database will take care of updating the version column by either using an actual VERSION column (if supported by the database in question) or by a trigger or a similar mechanism

How do I take care of updating the version column in the database?

Any help is much appreciated

Santiago
  • 982
  • 3
  • 14
  • 30

1 Answers1

1

If you are using JPA or its implementation you should be able to annotate your beans with:

@Version
private Long version;

So every time you persist you bean the version number will be increased by one automatically. In case you bean has lower/different version number during persisting it means it was changed in meantime and JPA throws Optimistic locking exception.

Milan Baran
  • 4,133
  • 2
  • 32
  • 49