/** * INTERNAL: * This method returns any of the fields that are not mapped in * the object. In the case of the value being stored in the * cache, a vector with one value is returned. In the case * of being stored in the object, an empty vector is returned. */ protected Vector getUnmappedFields() { Vector fields = new Vector(1); if (isStoredInCache()) { fields.addElement(getWriteLockField()); } return fields; }
/** * INTERNAL: * Return the value that should be stored in the identity map. * If the value is stored in the object, then return a null. */ public Object getValueToPutInCache(AbstractRecord row, AbstractSession session) { if (isStoredInCache()) { return row.get(getWriteLockField()); } else { return null; } }
/** * INTERNAL: * Return the value that should be stored in the identity map. * If the value is stored in the object, then return a null. */ public Object getValueToPutInCache(AbstractRecord row, AbstractSession session) { if (isStoredInCache()) { return row.get(getWriteLockField()); } else { return null; } }
/** * INTERNAL: * This method should merge changes from the parent into the child. * * #see this method in VersionLockingPolicy */ public void mergeIntoParentCache(CacheKey unitOfWorkCacheKey, CacheKey parentSessionCacheKey){ if (isStoredInCache() && unitOfWorkCacheKey != null && parentSessionCacheKey != null) { unitOfWorkCacheKey.setWriteLockValue(parentSessionCacheKey.getWriteLockValue()); } }
/** * INTERNAL: * Add update fields for template row. * These are any unmapped fields required to write in an update. */ public void addLockFieldsToUpdateRow(AbstractRecord databaseRow, AbstractSession session) { if (isStoredInCache()) { databaseRow.put(getWriteLockField(), null); } }
/** * INTERNAL: * Add update fields for template row. * These are any unmapped fields required to write in an update. */ public void addLockFieldsToUpdateRow(AbstractRecord databaseRow, AbstractSession session) { if (isStoredInCache()) { databaseRow.put(getWriteLockField(), null); } }
/** * INTERNAL: * Add update fields for template row. * These are any unmapped fields required to write in an update. */ public void addLockFieldsToUpdateRow(AbstractRecord databaseRow, AbstractSession session) { if (isStoredInCache()) { databaseRow.put(getWriteLockField(), null); } }
/** * INTERNAL: * Return the value that should be stored in the identity map. * If the value is stored in the object, then return a null. */ public Object getValueToPutInCache(AbstractRecord row, AbstractSession session) { if (isStoredInCache()) { return row.get(getWriteLockField()); } else { return null; } }
/** * INTERNAL: * This method should merge changes from the parent into the child. * * #see this method in VersionLockingPolicy */ public void mergeIntoParentCache(CacheKey unitOfWorkCacheKey, CacheKey parentSessionCacheKey){ if (isStoredInCache() && unitOfWorkCacheKey != null && parentSessionCacheKey != null) { unitOfWorkCacheKey.setWriteLockValue(parentSessionCacheKey.getWriteLockValue()); } }
/** * INTERNAL: * This method will return the optimistic lock value for the object */ public Object getWriteLockValue(Object domainObject, java.util.Vector primaryKey, AbstractSession session) { Number writeLockFieldValue; if (isStoredInCache()) { writeLockFieldValue = (Number)session.getIdentityMapAccessorInstance().getWriteLockValue(primaryKey, domainObject.getClass(), getDescriptor()); } else { writeLockFieldValue = (Number)lockValueFromObject(domainObject); } return writeLockFieldValue; }
/** * INTERNAL: * Only applicable when the value is stored in the cache. Will merge with the parent unit of work. */ public void mergeIntoParentCache(UnitOfWorkImpl uow, Object primaryKey, Object object) { if (isStoredInCache()) { Object parentValue = uow.getParentIdentityMapSession(descriptor, false, false).getIdentityMapAccessorInstance().getWriteLockValue(primaryKey, object.getClass(), getDescriptor()); uow.getIdentityMapAccessor().updateWriteLockValue(primaryKey, object.getClass(), parentValue); } }
/** * INTERNAL: * Only applicable when the value is stored in the cache. Will merge with the parent unit of work. */ public void mergeIntoParentCache(UnitOfWorkImpl uow, Vector primaryKey, Object object) { if (isStoredInCache()) { Object parentValue = uow.getParent().getIdentityMapAccessorInstance().getWriteLockValue(primaryKey, object.getClass(), getDescriptor()); uow.getIdentityMapAccessor().updateWriteLockValue(primaryKey, object.getClass(), parentValue); } }
/** * INTERNAL: * Only applicable when the value is stored in the cache. Will merge with the parent unit of work. */ public void mergeIntoParentCache(UnitOfWorkImpl uow, Object primaryKey, Object object) { if (isStoredInCache()) { Object parentValue = uow.getParentIdentityMapSession(descriptor, false, false).getIdentityMapAccessorInstance().getWriteLockValue(primaryKey, object.getClass(), getDescriptor()); uow.getIdentityMapAccessor().updateWriteLockValue(primaryKey, object.getClass(), parentValue); } }
/** * INTERNAL: * Compares the value with the value from the object (or cache). * Will return true if the currentValue is newer than the domainObject. */ public boolean isNewerVersion(Object currentValue, Object domainObject, Object primaryKey, AbstractSession session) { Number writeLockFieldValue; Number newWriteLockFieldValue = (Number)currentValue; if (isStoredInCache()) { writeLockFieldValue = (Number)session.getIdentityMapAccessorInstance().getWriteLockValue(primaryKey, domainObject.getClass(), getDescriptor()); } else { writeLockFieldValue = (Number)lockValueFromObject(domainObject); } return isNewerVersion(newWriteLockFieldValue, writeLockFieldValue); }
/** * INTERNAL: * This method updates the modify row, and the domain object * with the new lock value. */ public void updateRowAndObjectForUpdate(ObjectLevelModifyQuery query, Object domainObject) { Object lockValue = getNewLockValue(query); if (isStoredInCache()) { query.getSession().getIdentityMapAccessor().updateWriteLockValue(query.getPrimaryKey(), domainObject.getClass(), lockValue); } updateWriteLockValueForWrite(query, lockValue); }
/** * INTERNAL: * This method updates the modify row, and the domain object * with the new lock value. */ public void updateRowAndObjectForUpdate(ObjectLevelModifyQuery query, Object domainObject) { Object lockValue = getNewLockValue(query); if (isStoredInCache()) { query.getSession().getIdentityMapAccessor().updateWriteLockValue(query.getPrimaryKey(), domainObject.getClass(), lockValue); } updateWriteLockValueForWrite(query, lockValue); }
/** * INTERNAL: * This method updates the modify row, and the domain object * with the new lock value. */ public void updateRowAndObjectForUpdate(ObjectLevelModifyQuery query, Object domainObject) { Object lockValue = getNewLockValue(query); if (isStoredInCache()) { query.getSession().getIdentityMapAccessor().updateWriteLockValue(query.getPrimaryKey(), domainObject.getClass(), lockValue); } updateWriteLockValueForWrite(query, lockValue); }
/** * INTERNAL: * This method updates the modify row with the old lock value. */ public void writeLockValueIntoRow(ObjectLevelModifyQuery query, Object domainObject) { Object lockValue = getWriteLockValue(domainObject, query.getPrimaryKey(), query.getSession()); query.getModifyRow().put(this.writeLockField, lockValue); if (isStoredInCache()) { query.getSession().getIdentityMapAccessor().updateWriteLockValue(query.getPrimaryKey(), domainObject.getClass(), lockValue); } }
/** * INTERNAL: * This method updates the modify row with the old lock value. */ public void writeLockValueIntoRow(ObjectLevelModifyQuery query, Object domainObject) { Object lockValue = getWriteLockValue(domainObject, query.getPrimaryKey(), query.getSession()); query.getModifyRow().put(this.writeLockField, lockValue); if (isStoredInCache()) { query.getSession().getIdentityMapAccessor().updateWriteLockValue(query.getPrimaryKey(), domainObject.getClass(), lockValue); } }
/** * INTERNAL: * This method updates the modify row with the old lock value. */ public void writeLockValueIntoRow(ObjectLevelModifyQuery query, Object domainObject) { Object lockValue = getWriteLockValue(domainObject, query.getPrimaryKey(), query.getSession()); query.getModifyRow().put(this.writeLockField, lockValue); if (isStoredInCache()) { query.getSession().getIdentityMapAccessor().updateWriteLockValue(query.getPrimaryKey(), domainObject.getClass(), lockValue); } }