/** * INTERNAL: * Return if the map key this container policy represents is a OneToOne. */ @Override public boolean isMapKeyObject() { return ((DatabaseMapping)keyMapping).isOneToOneMapping(); }
/** * INTERNAL: * Return if the map key this container policy represents is a OneToOne. */ @Override public boolean isMapKeyObject() { return ((DatabaseMapping)keyMapping).isOneToOneMapping(); }
public boolean isOneToOneMapping() { return mapping.isOneToOneMapping(); }
/** * PUBLIC: Returns the default hierarchy traversal direction for the * specified mapping.<br> * For OneToOne mappings, source in parent object goes to target in * child object, collections are the opposite way. * * @param mapping * The mapping for which to return default hierarchy * traversal direction * @return The default hierarchy traversal direction for the mapping * passed */ public static Direction getDefault(DatabaseMapping mapping) { return mapping != null && mapping.isOneToOneMapping() ? CHILD_TO_PARENT : PARENT_TO_CHILD; } }
/** * PUBLIC: Returns the default hierarchy traversal direction for the * specified mapping.<br> * For OneToOne mappings, source in parent object goes to target in * child object, collections are the opposite way. * * @param mapping * The mapping for which to return default hierarchy * traversal direction * @return The default hierarchy traversal direction for the mapping * passed */ public static Direction getDefault(DatabaseMapping mapping) { return mapping != null && mapping.isOneToOneMapping() ? CHILD_TO_PARENT : PARENT_TO_CHILD; } }
/** * INTERNAL: * Process an association override for either an embedded object mapping, * or a map mapping (element-collection, 1-M and M-M) containing an * embeddable object as the value or key. */ @Override protected void processAssociationOverride(AssociationOverrideMetadata associationOverride, EmbeddableMapping embeddableMapping, MetadataDescriptor owningDescriptor) { if (getMapping().isOneToOneMapping()) { processAssociationOverride(associationOverride, embeddableMapping, owningDescriptor.getPrimaryTable(), owningDescriptor); } else { super.processAssociationOverride(associationOverride, embeddableMapping, owningDescriptor); } }
/** * INTERNAL: * Indicates whether this expression corresponds to OneToOne. */ public boolean isOneToOne() { if(getMapping() != null) { return getMapping().isOneToOneMapping(); } else { if(getQueryKeyOrNull() != null) { return this.queryKey.isOneToOneQueryKey(); } else { return false; } } }
/** * INTERNAL: * Indicates whether this expression corresponds to OneToOne. */ public boolean isOneToOne() { if(getMapping() != null) { return getMapping().isOneToOneMapping(); } else { if(getQueryKeyOrNull() != null) { return this.queryKey.isOneToOneQueryKey(); } else { return false; } } }
/** * INTERNAL: * Indicates whether this expression corresponds to OneToOne. */ public boolean isOneToOne() { if(getMapping() != null) { return getMapping().isOneToOneMapping(); } else { if(getQueryKeyOrNull() != null) { return this.queryKey.isOneToOneQueryKey(); } else { return false; } } }
/** * INTERNAL: * This method is for processing a single FieldResult, returning the DatabaseField it refers to. */ public DatabaseField processValueFromRecordForMapping(ClassDescriptor descriptor, String[] attributeNames, int currentLoc){ DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForAttributeName(attributeNames[currentLoc]); if (mapping==null){throw QueryException.mappingForFieldResultNotFound(attributeNames,currentLoc);} currentLoc++; if (attributeNames.length!=currentLoc){ ClassDescriptor currentDescriptor = mapping.getReferenceDescriptor(); DatabaseField df= processValueFromRecordForMapping(currentDescriptor, attributeNames, currentLoc); if (mapping.isOneToOneMapping()){ return (((OneToOneMapping)mapping).getTargetToSourceKeyFields().get(df)); } return df; }else{ //this is it.. return this mapping's field return mapping.getFields().firstElement(); } }
/** * INTERNAL: * This method is for processing a single FieldResult, returning the DatabaseField it refers to. */ public DatabaseField processValueFromRecordForMapping(ClassDescriptor descriptor, String[] attributeNames, int currentLoc){ DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForAttributeName(attributeNames[currentLoc]); if (mapping==null){throw QueryException.mappingForFieldResultNotFound(attributeNames,currentLoc);} currentLoc++; if (attributeNames.length!=currentLoc){ ClassDescriptor currentDescriptor = mapping.getReferenceDescriptor(); DatabaseField df= processValueFromRecordForMapping(currentDescriptor, attributeNames, currentLoc); if (mapping.isOneToOneMapping()){ return (((OneToOneMapping)mapping).getTargetToSourceKeyFields().get(df)); } return df; }else{ //this is it.. return this mapping's field return mapping.getFields().firstElement(); } }
/** * If the reference object is mapped thru one to one mapping and the object derives its primary key value * from this relationship then remote value holder has a primary key row for. */ protected boolean canDoCacheCheck() { if ((getMapping() == null) || (getQuery() == null)) { return false; } return (getTargetObjectPrimaryKeys() != null) && (!getTargetObjectPrimaryKeys().isEmpty()) && getMapping().isOneToOneMapping() && (!getQuery().shouldRefreshIdentityMapResult()) && (!getQuery().shouldRefreshRemoteIdentityMapResult()) && (getQuery().shouldMaintainCache()); }
/** * Get object from the cache if there is one. */ protected Object getObjectFromCache() { Object cachedObject = null; if (getMapping().isOneToOneMapping()) { ClassDescriptor descriptor = ((ObjectReferenceMapping)getMapping()).getReferenceDescriptor(); cachedObject = getSession().getIdentityMapAccessorInstance().getFromIdentityMap(getTargetObjectPrimaryKeys(), descriptor.getJavaClass(), descriptor); } return cachedObject; }
/** * Get object from the cache if there is one. */ protected Object getObjectFromCache() { Object cachedObject = null; if (getMapping().isOneToOneMapping()) { ClassDescriptor descriptor = ((ObjectReferenceMapping)getMapping()).getReferenceDescriptor(); cachedObject = getSession().getIdentityMapAccessorInstance().getFromIdentityMap(getTargetObjectPrimaryKeys(), descriptor.getJavaClass(), descriptor); } return cachedObject; }
/** * Get object from the cache if there is one. */ protected Object getObjectFromCache() { Object cachedObject = null; if (getMapping().isOneToOneMapping()) { ClassDescriptor descriptor = ((ObjectReferenceMapping)getMapping()).getReferenceDescriptor(); cachedObject = getSession().getIdentityMapAccessorInstance().getFromIdentityMap(getTargetObjectPrimaryKeys(), descriptor.getJavaClass(), descriptor); } return cachedObject; }
/** * If the reference object is mapped thru one to one mapping and the object derives its primary key value * from this relationship then remote value holder has a primary key row for. */ protected boolean canDoCacheCheck() { if ((getMapping() == null) || (getQuery() == null)) { return false; } return (getTargetObjectPrimaryKeys() != null) && getMapping().isOneToOneMapping() && (!getQuery().shouldRefreshIdentityMapResult()) && (!getQuery().shouldRefreshRemoteIdentityMapResult()) && (getQuery().shouldMaintainCache()); }
/** * If the reference object is mapped thru one to one mapping and the object derives its primary key value * from this relationship then remote value holder has a primary key row for. */ protected boolean canDoCacheCheck() { if ((getMapping() == null) || (getQuery() == null)) { return false; } return (getTargetObjectPrimaryKeys() != null) && getMapping().isOneToOneMapping() && (!getQuery().shouldRefreshIdentityMapResult()) && (!getQuery().shouldRefreshRemoteIdentityMapResult()) && (getQuery().shouldMaintainCache()); }
/** * INTERNAL: * The selection queries are created by cloning the source mapping, * updating the necessary database fields on the mapping and then * initializing the mapping to create the internal selection query. * This query is then cached where needed using the source mapping * as the key. A prepare is performed for each child of the hierarchy. */ protected void prepareSelectionQuery(DatabaseMapping sourceMapping, AbstractSession session) { // Recurse through our child descriptors to set up the selection query // before execution. for (ClassDescriptor childDescriptor : (Vector<ClassDescriptor>) getChildDescriptors()) { childDescriptor.getTablePerClassPolicy().prepareSelectionQuery(sourceMapping, session); } if (sourceMapping.isOneToManyMapping()) { prepareOneToManySelectionQuery((OneToManyMapping) sourceMapping, session); } else if (sourceMapping.isManyToManyMapping()) { prepareManyToManySelectionQuery((ManyToManyMapping) sourceMapping, session); } else if (sourceMapping.isOneToOneMapping()) { prepareOneToOneSelectionQuery((OneToOneMapping) sourceMapping, session); } // No support for other mappings at this point. }
/** * Synchronously create a remote value holder. The value holder passed in is ignored * so that we can ensure that the value holder being held by the object is used * instead of the one that was passed in. */ protected void internalIterateValueHolder(ValueHolderInterface originalValueHolder) { ValueHolderInterface rootValueHolder = originalValueHolder; // Ensure we have the base server side value holder. There will only be one of these per server. if (rootValueHolder instanceof RemoteValueHolder) { rootValueHolder = ((RemoteValueHolder)rootValueHolder).getWrappedServerValueHolder(); } synchronized (rootValueHolder) { ValueHolderInterface valueHolder = (ValueHolderInterface)getCurrentMapping().getAttributeValueFromObject(getVisitedParent()); RemoteValueHolder remoteValueHolder = buildRemoteValueHolderFor(valueHolder); if (valueHolder != remoteValueHolder) { if (this.getCurrentMapping().isOneToOneMapping()) { this.setOneToOneMappingSettingsIn(remoteValueHolder); } this.getCurrentMapping().setAttributeValueInObject(this.getVisitedParent(), remoteValueHolder); } } }
/** * Synchronously create a remote value holder. The value holder passed in is ignored * so that we can ensure that the value holder being held by the object is used * instead of the one that was passed in. */ protected void internalIterateValueHolder(ValueHolderInterface originalValueHolder) { ValueHolderInterface rootValueHolder = originalValueHolder; // Ensure we have the base server side value holder. There will only be one of these per server. if (rootValueHolder instanceof RemoteValueHolder) { rootValueHolder = ((RemoteValueHolder)rootValueHolder).getWrappedServerValueHolder(); } synchronized (rootValueHolder) { ValueHolderInterface valueHolder = (ValueHolderInterface)getCurrentMapping().getAttributeValueFromObject(getVisitedParent()); RemoteValueHolder remoteValueHolder = buildRemoteValueHolderFor(valueHolder); if (valueHolder != remoteValueHolder) { if (this.getCurrentMapping().isOneToOneMapping()) { this.setOneToOneMappingSettingsIn(remoteValueHolder); } this.getCurrentMapping().setAttributeValueInObject(this.getVisitedParent(), remoteValueHolder); } } }