}
@Transactional(readOnly = false)
public int save(Entity entity) throws ModelException {
TxnMode txnMode = entity.getTxnMode();
if (txnMode == null)
throw new ModelException("Please assign action type(insert, update, delete) before persist entity to database.");
int returnCode = 0;
entity.beforeSave();
if (txnMode.equals(TxnMode.INSERT))
returnCode = insert(entity);
else if (txnMode.equals(TxnMode.UPDATE))
returnCode = update(entity);
else if (txnMode.equals(TxnMode.DELETE))
returnCode = delete(entity);
entity.afterSave();
return returnCode;
}