Optimisticlock (attribute of entity)

From JRapid

(Redirected from Optimisticlock)
Jump to: navigation, search

The "optimisticlock" attribute specifies the optimistic locking strategy to take for resolving concurrent editions. You can either deny or prevent users of editing forms at the same time.

Contents

Usage

<entity label=LABEL name=LABEL optimisticlock="deny | warn">
  • When using optimisticlock = 'warn':
Optimistic lock "warn"
  • When using optimisticlock = 'deny':
Optimistic lock "deny"

Example:

<entity label="Company" name="Company" optimisticlock="deny">
  ...
</entity>

Generated code

  • When using optimisticlock = 'warn':
Session session = Session.getMySession();
if (voobj.getWriteTimestamp() != null && obj.getWriteTimestamp() != null 
   && obj.getWriteTimestamp() > voobj.getWriteTimestamp()) {
   if (!session.getConfirmations().contains("occ")) {
      throw new ConfirmationException("occ", "The user '" + obj.getReadLastUser() + "' has
      modified this object. Override his changes? ");
   }  		
}
obj.setWriteTimestamp(new java.util.Date().getTime());
obj.setWriteLastUser(session.getUsername());
  • When using optimisticlock = 'deny':
Session session = Session.getMySession();
if (voobj.getWriteTimestamp() != null && obj.getWriteTimestamp() != null &&
   obj.getWriteTimestamp() > voobj.getWriteTimestamp()) {
   throw new ServiceException("The user '" + obj.getReadLastUser() + "' has modified this
   object. ");     		
}
obj.setWriteTimestamp(new java.util.Date().getTime());
obj.setWriteLastUser(session.getUsername());

See Also

Personal tools