@Entity
public class Person {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private int salary;
@Version
private long version;
// ...getters and setters
}
- Is it required to create setter/getter for
version
? - When persisting this entity with Hibernate, I don t need to set this value manually, right?
- What else do I need to configure in order to use optimistic concurrency checking with Spring s
hibernateTemplate.saveOrUpdate
? Are all databases supported? - How to unit-test this entity? In my database all my records showing version field have value of 0
- Will calling
hibernateTemplate.saveOrUpdate
increment the version value every time?