2
What is and what is the "Optimistic Locking Field" of JPA? I noticed that there is this option for Eclipse Link and Hibernate and this function is enabled when annotating a version attribute within an entity class, but I did not understand what its purpose, when I should use and what its advantages.
Class example annotated with @version
@Entity
public class Inventory {
@Id
@Column(name="ITEM_SKU", insertable=false, updatable=false)
protected long id;
@OneToOne
@JoinColumn(name="ITEM_SKU")
protected Item item;
...
@Version
protected int version;
...
public void setItem(Item item) {
this.item = item;
this.id = item.getSKU();
}
}
This link can help you: http://www.byteslounge.com/tutorials/jpa-entity-versioning-version-and-optimistic-locking
– Murillo Goulart