/** * Records that all instance fields are/are not dirty, * and changes the flags of the instance accordingly. */ void setDirty(boolean val) { FieldMetaData[] fmds = _meta.getFields(); boolean update = !isNew() || isFlushed(); for (int i = 0; i < fmds.length; i++) { if (val && (!update || fmds[i].getUpdateStrategy() != UpdateStrategies.IGNORE)) _dirty.set(i); else if (!val) { // we never consider clean fields flushed; this also takes // care of clearing the flushed fields on commit/rollback _flush.clear(i); _dirty.clear(i); } } if (val) _flags |= FLAG_LOADED; }
private boolean needsDirtyCheck() { if (isIntercepting()) return false; if (isDeleted()) return false; if (isNew() && !isFlushed()) return false; return true; }
private boolean needsDirtyCheck() { if (isIntercepting()) return false; if (isDeleted()) return false; if (isNew() && !isFlushed()) return false; return true; }
private boolean needsDirtyCheck() { if (isIntercepting()) return false; if (isDeleted()) return false; if (isNew() && !isFlushed()) return false; return true; }
private boolean needsDirtyCheck() { if (isIntercepting()) return false; if (isDeleted()) return false; if (isNew() && !isFlushed()) return false; return true; }
/** * Constructor. Provide {@link StateManagerImpl} of instance to save. */ SaveFieldManager(StateManagerImpl sm, PersistenceCapable pc, BitSet dirty) { _sm = sm; _state = pc; // if instance is new or transient all fields will be marked dirty even // though they have their original values, so we can restore them; // otherwise, we need to record already-dirty persistent fields as // ones we won't be able to restore FieldMetaData[] fields = _sm.getMetaData().getFields(); if (_sm.isNew() || !_sm.isPersistent() || dirty == null) _unloaded = new BitSet(fields.length); else { _unloaded = (BitSet) dirty.clone(); for (int i = 0; i < fields.length; i++) if (fields[i].getManagement() != fields[i].MANAGE_PERSISTENT) _unloaded.clear(i); } }
/** * Constructor. Provide {@link StateManagerImpl} of instance to save. */ SaveFieldManager(StateManagerImpl sm, PersistenceCapable pc, BitSet dirty) { _sm = sm; _state = pc; // if instance is new or transient all fields will be marked dirty even // though they have their original values, so we can restore them; // otherwise, we need to record already-dirty persistent fields as // ones we won't be able to restore FieldMetaData[] fields = _sm.getMetaData().getFields(); if (_sm.isNew() || !_sm.isPersistent() || dirty == null) _unloaded = new BitSet(fields.length); else { _unloaded = (BitSet) dirty.clone(); for (int i = 0; i < fields.length; i++) if (fields[i].getManagement() != fields[i].MANAGE_PERSISTENT) _unloaded.clear(i); } }
/** * This method makes sure we don't already have the instance cached */ protected void checkForDuplicateId(Object id, Object obj) { StateManagerImpl other = getStateManagerImplById(id, false); if (other != null && !other.isDeleted() && !other.isNew()) throw new ObjectExistsException(_loc.get("cache-exists", obj.getClass().getName(), id)).setFailedObject(obj); } }
/** * Constructor. Provide {@link StateManagerImpl} of instance to save. */ SaveFieldManager(StateManagerImpl sm, PersistenceCapable pc, BitSet dirty) { _sm = sm; _state = pc; // if instance is new or transient all fields will be marked dirty even // though they have their original values, so we can restore them; // otherwise, we need to record already-dirty persistent fields as // ones we won't be able to restore FieldMetaData[] fields = _sm.getMetaData().getFields(); if (_sm.isNew() || !_sm.isPersistent() || dirty == null) _unloaded = new BitSet(fields.length); else { _unloaded = (BitSet) dirty.clone(); for (int i = 0; i < fields.length; i++) if (fields[i].getManagement() != fields[i].MANAGE_PERSISTENT) _unloaded.clear(i); } }
/** * Constructor. Provide {@link StateManagerImpl} of instance to save. */ SaveFieldManager(StateManagerImpl sm, PersistenceCapable pc, BitSet dirty) { _sm = sm; _state = pc; // if instance is new or transient all fields will be marked dirty even // though they have their original values, so we can restore them; // otherwise, we need to record already-dirty persistent fields as // ones we won't be able to restore FieldMetaData[] fields = _sm.getMetaData().getFields(); if (_sm.isNew() || !_sm.isPersistent() || dirty == null) _unloaded = new BitSet(fields.length); else { _unloaded = (BitSet) dirty.clone(); for (int i = 0; i < fields.length; i++) if (fields[i].getManagement() != fields[i].MANAGE_PERSISTENT) _unloaded.clear(i); } }
private boolean needsDirtyCheck() { if (isIntercepting()) return false; if (isDeleted()) return false; if (isNew() && !isFlushed()) return false; return true; }
/** * This method makes sure we don't already have the instance cached */ protected void checkForDuplicateId(Object id, Object obj, ClassMetaData meta) { FieldMetaData[] pks = meta.getPrimaryKeyFields(); if (pks != null && pks.length == 1 && pks[0].getValueStrategy() == ValueStrategies.AUTOASSIGN) { return; } StateManagerImpl other = getStateManagerImplById(id, false); if (other != null && !other.isDeleted() && !other.isNew()) throw new ObjectExistsException(_loc.get("cache-exists", obj.getClass().getName(), id)).setFailedObject(obj); }
/** * This method makes sure we don't already have the instance cached */ protected void checkForDuplicateId(Object id, Object obj, ClassMetaData meta) { FieldMetaData[] pks = meta.getPrimaryKeyFields(); if (pks != null && pks.length == 1 && pks[0].getValueStrategy() == ValueStrategies.AUTOASSIGN) { return; } StateManagerImpl other = getStateManagerImplById(id, false); if (other != null && !other.isDeleted() && !other.isNew()) throw new ObjectExistsException(_loc.get("cache-exists", obj.getClass().getName(), id)).setFailedObject(obj); }
/** * This method makes sure we don't already have the instance cached */ protected void checkForDuplicateId(Object id, Object obj, ClassMetaData meta) { FieldMetaData[] pks = meta.getPrimaryKeyFields(); if (pks != null && pks.length == 1 && pks[0].getValueStrategy() == ValueStrategies.AUTOASSIGN) { return; } StateManagerImpl other = getStateManagerImplById(id, false); if (other != null && !other.isDeleted() && !other.isNew()) throw new ObjectExistsException(_loc.get("cache-exists", obj.getClass().getName(), id)).setFailedObject(obj); }
/** * This method makes sure we don't already have the instance cached */ protected void checkForDuplicateId(Object id, Object obj, ClassMetaData meta) { FieldMetaData[] pks = meta.getPrimaryKeyFields(); if (pks != null && pks.length == 1 && pks[0].getValueStrategy() == ValueStrategies.AUTOASSIGN) { return; } StateManagerImpl other = getStateManagerImplById(id, false); if (other != null && !other.isDeleted() && !other.isNew()) throw new ObjectExistsException(_loc.get("cache-exists", obj.getClass().getName(), id)).setFailedObject(obj); }
/** * Records that all instance fields are/are not dirty, * and changes the flags of the instance accordingly. */ void setDirty(boolean val) { FieldMetaData[] fmds = _meta.getFields(); boolean update = !isNew() || isFlushed(); for (int i = 0; i < fmds.length; i++) { if (val && (!update || fmds[i].getUpdateStrategy() != UpdateStrategies.IGNORE)) setFieldDirty(i); else if (!val) { // we never consider clean fields flushed; this also takes // care of clearing the flushed fields on commit/rollback clearFlushField(i); clearDirty(i); } } if (val) _flags |= FLAG_LOADED; }
/** * Load the state of this instance based on the given fetch configuration * and load mode. Return true if any data was loaded, false otherwise. */ protected boolean load(FetchConfiguration fetch, int loadMode, BitSet exclude, Object sdata, boolean forWrite) { if (!forWrite && (!isPersistent() || isNew() || isDeleted())) return false; // if any fields being loaded, do state transitions for read BitSet fields = getUnloadedInternal(fetch, loadMode, exclude); boolean active = _broker.isActive(); if (!forWrite && fields != null) beforeRead(-1); // call load even if no fields are being loaded, because it takes // care of checking if the DFG is loaded, making sure version info // is loaded, etc int lockLevel = calculateLockLevel(active, forWrite, fetch); boolean ret = loadFields(fields, fetch, lockLevel, sdata); obtainLocks(active, forWrite, lockLevel, fetch, sdata); return ret; }
/** * Load the state of this instance based on the given fetch configuration * and load mode. Return true if any data was loaded, false otherwise. */ protected boolean load(FetchConfiguration fetch, int loadMode, BitSet exclude, Object sdata, boolean forWrite) { if (!forWrite && (!isPersistent() || (isNew() && !isFlushed()) || isDeleted())) return false; // if any fields being loaded, do state transitions for read BitSet fields = getUnloadedInternal(fetch, loadMode, exclude); boolean active = _broker.isActive(); if (!forWrite && fields != null) beforeRead(-1); // call load even if no fields are being loaded, because it takes // care of checking if the DFG is loaded, making sure version info // is loaded, etc int lockLevel = calculateLockLevel(active, forWrite, fetch); boolean ret = loadFields(fields, fetch, lockLevel, sdata); obtainLocks(active, forWrite, lockLevel, fetch, sdata); return ret; }
/** * Load the state of this instance based on the given fetch configuration * and load mode. Return true if any data was loaded, false otherwise. */ protected boolean load(FetchConfiguration fetch, int loadMode, BitSet exclude, Object sdata, boolean forWrite) { if (!forWrite && (!isPersistent() || (isNew() && !isFlushed()) || isDeleted())) return false; // if any fields being loaded, do state transitions for read BitSet fields = getUnloadedInternal(fetch, loadMode, exclude); boolean active = _broker.isActive(); if (!forWrite && fields != null) beforeRead(-1); // call load even if no fields are being loaded, because it takes // care of checking if the DFG is loaded, making sure version info // is loaded, etc int lockLevel = calculateLockLevel(active, forWrite, fetch); boolean ret = loadFields(fields, fetch, lockLevel, sdata); obtainLocks(active, forWrite, lockLevel, fetch, sdata); return ret; }
/** * Load the state of this instance based on the given fetch configuration * and load mode. Return true if any data was loaded, false otherwise. */ protected boolean load(FetchConfiguration fetch, int loadMode, BitSet exclude, Object sdata, boolean forWrite) { if (!forWrite && (!isPersistent() || (isNew() && !isFlushed()) || isDeleted())) return false; // if any fields being loaded, do state transitions for read BitSet fields = getUnloadedInternal(fetch, loadMode, exclude); boolean active = _broker.isActive(); if (!forWrite && fields != null) beforeRead(-1); // call load even if no fields are being loaded, because it takes // care of checking if the DFG is loaded, making sure version info // is loaded, etc int lockLevel = calculateLockLevel(active, forWrite, fetch); boolean ret = loadFields(fields, fetch, lockLevel, sdata); obtainLocks(active, forWrite, lockLevel, fetch, sdata); return ret; }