Nice idea and seems to work.
I changed to Integer version, because as you all said it is recommended and
timestamp is sligthly less safe.
So I have this now:
Index.class
public class Index {
@Inject
private PersonRepository personRepo;
@Property
private Person person;
@CommitAfter
void onSuccess() {
}
void onActivate(Integer personId, Integer version) {
if(person == null) {
person = personRepo.get(personId);
}
if(person.getVersion() != version) {
throw new RuntimeException("ERROR!");
}
}
Integer[] onPassivate() {
return new Integer[] { person.getId(), person.getVersion() };
}
}
Index.tml:
<t:form>
<t:textfield t:value="person.name" />
<t:submit />
</t:form>
--
View this message in context:
http://tapestry.1045711.n5.nabble.com/Tapestry-Hibernate-optimistic-locking-tp5718413p5718425.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]