Thursday, April 25, 2013

Concurrent Modification in JPA :


We can handle the concurrent modification issue by using the annotaion @Version in entity class.
 
E.g : 
    @Version
    @Column(name = "LAST_MODIFIED_TIME")
    private Date lastModifiedDate
 
  @version implies a version field in an entity.JPA uses a version field to detect concurrent modifications of a database record.
 
  it throws an exception to the transaction attempting to commit cuncurrent modification.
This prevents you from overwriting the previous commit.

No comments:

Post a Comment