ClassDescriptor descriptor = nodeValue.getMapping().getReferenceDescriptor();
/** * {@inheritDoc} */ @Override public Object getReferenceManagedType(Object mapping) { if (mapping == null) { return null; } return ((DatabaseMapping) mapping).getReferenceDescriptor(); }
/** * {@inheritDoc} */ @Override public Object getReferenceManagedType(Object mapping) { if (mapping == null) { return null; } return ((DatabaseMapping) mapping).getReferenceDescriptor(); }
/** * Add a mapping to the list of mappings that require postCalculateChanges method to be called. */ public void addMappingsPostCalculateChanges(DatabaseMapping mapping) { //474752 :ReferenceDescriptor may not be available during //predeploy. It is required for calculating changes. if (mapping.getReferenceDescriptor() != null) { getMappingsPostCalculateChanges().add(mapping); } }
/** * INTERNAL: * Add the key and value from provided association to the deleted objects list on the commit manager. */ @Override public void recordPrivateOwnedRemovals(Object object,ClassDescriptor referenceDescriptor, UnitOfWorkImpl uow){ if (((DatabaseMapping)keyMapping).isPrivateOwned()){ Object key = ((Map.Entry)object).getKey(); ((DatabaseMapping)keyMapping).getReferenceDescriptor().getObjectBuilder().recordPrivateOwnedRemovals(key, uow, false); } super.recordPrivateOwnedRemovals(((Map.Entry)object).getValue(), referenceDescriptor, uow); }
/** * INTERNAL: * Add the key and value from provided association to the deleted objects list on the commit manager. */ @Override public void recordPrivateOwnedRemovals(Object object,ClassDescriptor referenceDescriptor, UnitOfWorkImpl uow){ if (((DatabaseMapping)keyMapping).isPrivateOwned()){ Object key = ((Map.Entry)object).getKey(); ((DatabaseMapping)keyMapping).getReferenceDescriptor().getObjectBuilder().recordPrivateOwnedRemovals(key, uow, false); } super.recordPrivateOwnedRemovals(((Map.Entry)object).getValue(), referenceDescriptor, uow); }
/** * INTERNAL: * Add the key and value from provided association to the deleted objects list on the commit manager. * * @see ContainerPolicy * @param object * @param manager */ @Override public void recordPrivateOwnedRemovals(Object object,ClassDescriptor referenceDescriptor, UnitOfWorkImpl uow){ if (((DatabaseMapping)keyMapping).isPrivateOwned()){ Object key = ((Map.Entry)object).getKey(); ((DatabaseMapping)keyMapping).getReferenceDescriptor().getObjectBuilder().recordPrivateOwnedRemovals(key, uow, false); } super.recordPrivateOwnedRemovals(((Map.Entry)object).getValue(), referenceDescriptor, uow); }
@Override public boolean isForeignJoinColumn(EntityType<?> ownerType, String attributeName) { ManagedTypeImpl<?> managedType = (ManagedTypeImpl<?>) ownerType; String[] parts = attributeName.split("\\."); DatabaseMapping mapping = managedType.getDescriptor().getMappingForAttributeName(parts[0]); for (int i = 1; i < parts.length; i++) { mapping = mapping.getReferenceDescriptor().getMappingForAttributeName(parts[i]); } if (mapping instanceof OneToOneMapping) { return ((OneToOneMapping) mapping).hasRelationTable(); } return false; }
@Override public boolean isForeignJoinColumn(EntityType<?> ownerType, String attributeName) { ManagedTypeImpl<?> managedType = (ManagedTypeImpl<?>) ownerType; String[] parts = attributeName.split("\\."); DatabaseMapping mapping = managedType.getDescriptor().getMappingForAttributeName(parts[0]); for (int i = 1; i < parts.length; i++) { mapping = mapping.getReferenceDescriptor().getMappingForAttributeName(parts[i]); } if (mapping instanceof OneToOneMapping) { return ((OneToOneMapping) mapping).hasRelationTable(); } return false; }
/** * resolveClass: Answer the class for the mapping associated with the my variableName in the ownerClass. * Answer null if the node represents a mapping that doesn't exist */ public Class resolveClass(GenerationContext context, Class ownerClass) { DatabaseMapping mapping; mapping = resolveMapping(context, ownerClass); // if we are working with a direct-to-field, or the mapping's null, // return the owner class // Returning the ownerClass when the mapping is null delegates error handling // to the query rather than me if ((mapping == null) || (mapping.isDirectToFieldMapping())) { return ownerClass; } ClassDescriptor descriptor = mapping.getReferenceDescriptor(); return (descriptor==null) ? null : descriptor.getJavaClass(); //return mapping.getReferenceDescriptor().getJavaClass(); }
/** * resolveClass: Answer the class for the mapping associated with the my variableName in the ownerClass. * Answer null if the node represents a mapping that doesn't exist */ public Class resolveClass(GenerationContext context, Class ownerClass) { DatabaseMapping mapping; mapping = resolveMapping(context, ownerClass); // if we are working with a direct-to-field, or the mapping's null, // return the owner class // Returning the ownerClass when the mapping is null delegates error handling // to the query rather than me if ((mapping == null) || (mapping.isDirectToFieldMapping())) { return ownerClass; } ClassDescriptor descriptor = mapping.getReferenceDescriptor(); return (descriptor==null) ? null : descriptor.getJavaClass(); //return mapping.getReferenceDescriptor().getJavaClass(); }
/** * resolveClass: Answer the class for the mapping associated with the my variableName in the ownerClass. * Answer null if the node represents a mapping that doesn't exist */ public Class resolveClass(GenerationContext context, Class ownerClass) { DatabaseMapping mapping; mapping = resolveMapping(context, ownerClass); // if we are working with a direct-to-field, or the mapping's null, // return the owner class // Returning the ownerClass when the mapping is null delegates error handling // to the query rather than me if ((mapping == null) || (mapping.isDirectToFieldMapping())) { return ownerClass; } ClassDescriptor descriptor = mapping.getReferenceDescriptor(); return (descriptor==null) ? null : descriptor.getJavaClass(); //return mapping.getReferenceDescriptor().getJavaClass(); }
@Override public DatabaseField getTypedField(DatabaseField field) { XMLField foundField = (XMLField) super.getTypedField(field); if(null != foundField) { return foundField; } StringTokenizer stringTokenizer = new StringTokenizer(field.getName(), String.valueOf(XPATH_FRAGMENT_SEPARATOR)); DatabaseField typedField = getTypedField(stringTokenizer); if(null == typedField) { DatabaseMapping selfMapping = objectBuilder.getMappingForField(new XMLField(".")); if(null != selfMapping) { return selfMapping.getReferenceDescriptor().getTypedField(field); } } return typedField; }
@Override public DatabaseField getTypedField(DatabaseField field) { XMLField foundField = (XMLField) super.getTypedField(field); if(null != foundField) { return foundField; } StringTokenizer stringTokenizer = new StringTokenizer(field.getName(), String.valueOf(XPATH_FRAGMENT_SEPARATOR)); DatabaseField typedField = getTypedField(stringTokenizer); if(null == typedField) { DatabaseMapping selfMapping = objectBuilder.getMappingForField(new XMLField(".")); if(null != selfMapping) { return selfMapping.getReferenceDescriptor().getTypedField(field); } } return typedField; }
/** * INTERNAL: * Iterate through a list of joined expressions and add the fields they represent to a list * of fields. */ protected void addSelectionFieldsForJoinedExpressions(List fields, List joinedExpressions) { for (int index = 0; index < joinedExpressions.size(); index++) { ObjectExpression objectExpression = (ObjectExpression)joinedExpressions.get(index); // Expression may not have been initialized. ExpressionBuilder builder = objectExpression.getBuilder(); builder.setSession(getSession().getRootSession(null)); builder.setQueryClass(getReferenceClass()); ClassDescriptor descriptor = objectExpression.getMapping().getReferenceDescriptor(); fields.addAll(descriptor.getAllFields()); } }
@Override public DatabaseField getTypedField(DatabaseField field) { XMLField foundField = (XMLField) super.getTypedField(field); if(null != foundField) { return foundField; } StringTokenizer stringTokenizer = new StringTokenizer(field.getName(), "/"); DatabaseField typedField = getTypedField(stringTokenizer); if(null == typedField) { DatabaseMapping selfMapping = objectBuilder.getMappingForField(new XMLField(".")); if(null != selfMapping) { return selfMapping.getReferenceDescriptor().getTypedField(field); } } return typedField; }
/** * INTERNAL: * Configure all descriptors referencing this class to be protected and update their cache settings. */ public void notifyReferencingDescriptorsOfIsolation(AbstractSession session) { for (ClassDescriptor descriptor : this.referencingClasses){ if (descriptor.getCachePolicy().getCacheIsolation() == null || descriptor.getCachePolicy().getCacheIsolation() == CacheIsolationType.SHARED) { descriptor.getCachePolicy().setCacheIsolation(CacheIsolationType.PROTECTED); descriptor.getCachePolicy().postInitialize(descriptor, session); for (DatabaseMapping mapping : descriptor.getMappings()) { if (mapping.isAggregateMapping() && (mapping.getReferenceDescriptor() != null)) { mapping.getReferenceDescriptor().getCachePolicy().setCacheIsolation(CacheIsolationType.PROTECTED); } } } } }
/** * INTERNAL: * This method is used to store the FK fields that can be cached that correspond to noncacheable mappings * the FK field values will be used to re-issue the query when cloning the shared cache entity */ @Override public void collectQueryParameters(Set<DatabaseField> record){ for (DatabaseMapping mapping : getReferenceDescriptor().getMappings()){ if ((mapping.isForeignReferenceMapping() && !mapping.isCacheable()) || (mapping.isAggregateObjectMapping() && mapping.getReferenceDescriptor().hasNoncacheableMappings())){ ((ForeignReferenceMapping) mapping).collectQueryParameters(record); } } }
/** * INTERNAL: * Configure all descriptors referencing this class to be protected and update their cache settings. */ public void notifyReferencingDescriptorsOfIsolation(AbstractSession session) { for (ClassDescriptor descriptor : this.referencingClasses){ if (descriptor.getCachePolicy().getCacheIsolation() == null || descriptor.getCachePolicy().getCacheIsolation() == CacheIsolationType.SHARED) { descriptor.getCachePolicy().setCacheIsolation(CacheIsolationType.PROTECTED); descriptor.getCachePolicy().postInitialize(descriptor, session); for (DatabaseMapping mapping : descriptor.getMappings()) { if (mapping.isAggregateMapping() && (mapping.getReferenceDescriptor() != null)) { mapping.getReferenceDescriptor().getCachePolicy().setCacheIsolation(CacheIsolationType.PROTECTED); } } } } }
/** * INTERNAL: * This method is used to store the FK fields that can be cached that correspond to noncacheable mappings * the FK field values will be used to re-issue the query when cloning the shared cache entity */ @Override public void collectQueryParameters(Set<DatabaseField> record){ for (DatabaseMapping mapping : getReferenceDescriptor().getMappings()){ if ((mapping.isForeignReferenceMapping() && !mapping.isCacheable()) || (mapping.isAggregateObjectMapping() && mapping.getReferenceDescriptor().hasNoncacheableMappings())){ ((ForeignReferenceMapping) mapping).collectQueryParameters(record); } } }