/** * This method tries to get an object from any of the scopes (invoking the <code>get(IntactObject)</code> method. * If it does not exist, it adds it to the SyncContext and returns the newly synced object. * @param intactObject The object to sync (if transient) * @return a synced object, which can be itself or a previously equal synced object */ public T syncIfTransient(T intactObject) { if (log.isDebugEnabled()) log.debug("\t\tSyncing "+intactObject.getClass().getSimpleName()+": "+intactObject.getShortLabel()); T refreshedObject = get(intactObject); if (refreshedObject != null) { if (log.isDebugEnabled()) log.debug("\t\t\tAlready synced: " + intactObject.getClass().getSimpleName() + "(" + intactObject.getShortLabel() + " - " + intactObject.getAc() + ")"); return refreshedObject; } if ( log.isDebugEnabled() ) { log.debug( "\t\t\tAdding to SyncContext. Key: "+ AnnotKeyGenerator.createKey(intactObject)); } SyncContext.getInstance().addToSynced(intactObject); return syncAttributes(intactObject); }
/** * Checks is the given object already synchronized with the persistence session. * @param intactObject object to be synced. * @return a response that contains the answer. */ protected final SyncTransientResponse<T> syncIfTransientResponse(T intactObject) { T refreshedObject = syncIfTransient(intactObject); if (refreshedObject.getAc() != null) { return new SyncTransientResponse<T>(true, refreshedObject); } return new SyncTransientResponse<T>(false, syncAttributes(intactObject)); }