/** * INTERNAL: * Build a list of all the interfaces and super interfaces for a given class. */ public Collection buildTargetInterfaces(Class aClass, Collection targetInterfacesCol) { Class[] targetInterfaces = aClass.getInterfaces(); for (int index = 0; index < targetInterfaces.length; index++) { targetInterfacesCol.add(targetInterfaces[index]); } if (aClass.getSuperclass() == null) { return targetInterfacesCol; } else { return buildTargetInterfaces(aClass.getSuperclass(), targetInterfacesCol); } }
/** * INTERNAL: * Cascade discover and persist new objects during commit. */ @Override public void cascadeDiscoverAndPersistUnregisteredNewObjects(Object object, Map newObjects, Map unregisteredExistingObjects, Map visitedObjects, UnitOfWorkImpl uow, Set cascadeErrors) { cascadeDiscoverAndPersistUnregisteredNewObjects(object, newObjects, unregisteredExistingObjects, visitedObjects, uow, true, cascadeErrors); }
/** * INTERNAL: * Cascade registerNew for Create through mappings that require the cascade */ @Override public void cascadePerformRemoveIfRequired(Object object, UnitOfWorkImpl uow, Map visitedObjects){ cascadePerformRemoveIfRequired(object, uow, visitedObjects, true); }
/** * Set one-to-one mapping information. * This allows us to look for a cache hit * before going to the database. */ protected void setOneToOneMappingSettingsIn(RemoteValueHolder remoteValueHolder) { ObjectReferenceMapping oneToOneMapping = (ObjectReferenceMapping)this.getCurrentMapping();// cast it if (oneToOneMapping.getDescriptor().getObjectBuilder().isPrimaryKeyMapping(oneToOneMapping)) { remoteValueHolder.setRow(oneToOneMapping.extractPrimaryKeyRowForSourceObject(this.getVisitedParent(), this.getSession())); } remoteValueHolder.setTargetObjectPrimaryKeys(oneToOneMapping.extractPrimaryKeysForReferenceObject(this.getVisitedParent(), this.getSession())); } }
/** * INTERNAL: * Get a value from the object and set that in the respective field of the row. * But before that check if the reference object is instantiated or not. */ public void writeFromObjectIntoRowForUpdate(WriteObjectQuery query, AbstractRecord databaseRow) { Object object = query.getObject(); AbstractSession session = query.getSession(); if (!isAttributeValueInstantiated(object)) { return; } if (session.isUnitOfWork()) { if (compareObjectsWithoutPrivateOwned(query.getBackupClone(), object, session)) { return; } } writeFromObjectIntoRow(object, databaseRow, session); }
Class[] targetInterfaces = getReferenceClass().getInterfaces(); if (!getReferenceClass().isInterface() && getReferenceClass().getSuperclass() == null) { setIndirectionPolicy(new ProxyIndirectionPolicy(targetInterfaces)); } else { HashSet targetInterfacesCol = new HashSet(); if (getReferenceClass().getSuperclass() != null) { buildTargetInterfaces(getReferenceClass(), targetInterfacesCol); if (getReferenceClass().isInterface()) { targetInterfacesCol.add(getReferenceClass()); setIndirectionPolicy(new ProxyIndirectionPolicy(targetInterfaces));
DatabaseValueHolder valueHolder = null; if ((row == null && original != null) && (isPrimaryKeyMapping())) { AbstractRecord rowFromTargetObject = extractPrimaryKeyRowForSourceObject(original, cloningSession); valueHolder = cloningSession.createCloneQueryValueHolder(attributeValue, clone, rowFromTargetObject, this); } else {
VariableOneToOneMapping clone = (VariableOneToOneMapping)super.clone(); Map setOfKeys = new HashMap(getSourceToTargetQueryKeyNames().size()); Map sourceToTarget = new HashMap(getSourceToTargetQueryKeyNames().size());
/** * INTERNAL: * Cascade registerNew for Create through mappings that require the cascade */ public void cascadeRegisterNewIfRequired(Object object, UnitOfWorkImpl uow, Map visitedObjects){ cascadeRegisterNewIfRequired(object, uow, visitedObjects, true); }
/** * INTERNAL: * Return all the fields populated by this mapping, these are foreign keys only. */ protected Vector<DatabaseField> collectFields() { if(this.mechanism != null) { return new Vector(0); } else { return super.collectFields(); } } }
/** * INTERNAL: * Adds locking clause to the target query to extend pessimistic lock scope. */ @Override protected void extendPessimisticLockScopeInTargetQuery(ObjectLevelReadQuery targetQuery, ObjectBuildingQuery sourceQuery) { if(this.mechanism == null) { super.extendPessimisticLockScopeInTargetQuery(targetQuery, sourceQuery); } else { this.mechanism.setRelationTableLockingClause(targetQuery, sourceQuery); } }
super.convertClassNamesToClasses(classLoader); Iterator iterator = getTypeIndicatorNameTranslation().entrySet().iterator(); this.typeIndicatorTranslation = new HashMap();
/** * Set one-to-one mapping information. * This allows us to look for a cache hit * before going to the database. */ protected void setOneToOneMappingSettingsIn(RemoteValueHolder remoteValueHolder) { ObjectReferenceMapping oneToOneMapping = (ObjectReferenceMapping)this.getCurrentMapping();// cast it if (oneToOneMapping.getDescriptor().getObjectBuilder().isPrimaryKeyMapping(oneToOneMapping)) { remoteValueHolder.setRow(oneToOneMapping.extractPrimaryKeyRowForSourceObject(this.getVisitedParent(), this.getSession())); } remoteValueHolder.setTargetObjectPrimaryKeys(oneToOneMapping.extractPrimaryKeysForReferenceObject(this.getVisitedParent(), this.getSession())); } }
/** * INTERNAL: * Get a value from the object and set that in the respective field of the row. * But before that check if the reference object is instantiated or not. */ @Override public void writeFromObjectIntoRowForUpdate(WriteObjectQuery query, AbstractRecord databaseRow) { Object object = query.getObject(); AbstractSession session = query.getSession(); if (!isAttributeValueInstantiated(object)) { return; } if (session.isUnitOfWork()) { if (compareObjectsWithoutPrivateOwned(query.getBackupClone(), object, session)) { return; } } writeFromObjectIntoRow(object, databaseRow, session, WriteType.UPDATE); }
Class[] targetInterfaces = getReferenceClass().getInterfaces(); if (!getReferenceClass().isInterface() && getReferenceClass().getSuperclass() == null) { setIndirectionPolicy(new ProxyIndirectionPolicy(targetInterfaces)); } else { HashSet targetInterfacesCol = new HashSet(); if (getReferenceClass().getSuperclass() != null) { buildTargetInterfaces(getReferenceClass(), targetInterfacesCol); if (getReferenceClass().isInterface()) { targetInterfacesCol.add(getReferenceClass()); setIndirectionPolicy(new ProxyIndirectionPolicy(targetInterfaces));
DatabaseValueHolder valueHolder = null; if ((row == null && original != null) && (isPrimaryKeyMapping())) { AbstractRecord rowFromTargetObject = extractPrimaryKeyRowForSourceObject(original, cloningSession); valueHolder = cloningSession.createCloneQueryValueHolder(attributeValue, clone, rowFromTargetObject, this); } else {
VariableOneToOneMapping clone = (VariableOneToOneMapping)super.clone(); Map setOfKeys = new HashMap(getSourceToTargetQueryKeyNames().size()); Map sourceToTarget = new HashMap(getSourceToTargetQueryKeyNames().size());
/** * INTERNAL: * Cascade registerNew for Create through mappings that require the cascade */ @Override public void cascadeRegisterNewIfRequired(Object object, UnitOfWorkImpl uow, Map visitedObjects){ cascadeRegisterNewIfRequired(object, uow, visitedObjects, true); }
/** * INTERNAL: * Return all the fields populated by this mapping, these are foreign keys only. */ @Override protected Vector<DatabaseField> collectFields() { if(this.mechanism != null) { return new Vector(0); } else { return super.collectFields(); } }
/** * INTERNAL: * Adds locking clause to the target query to extend pessimistic lock scope. */ protected void extendPessimisticLockScopeInTargetQuery(ObjectLevelReadQuery targetQuery, ObjectBuildingQuery sourceQuery) { if(this.mechanism == null) { super.extendPessimisticLockScopeInTargetQuery(targetQuery, sourceQuery); } else { this.mechanism.setRelationTableLockingClause(targetQuery, sourceQuery); } }