/** * PUBLIC: * The classification type for the attribute this mapping represents */ @Override public Class getAttributeClassification() { return getReferenceClass(); }
/** * PUBLIC: * The classification type for the attribute this mapping represents */ @Override public Class getAttributeClassification() { return getReferenceClass(); }
@Override public void customizeColumnName(final String tableName, final AggregateObjectMapping databaseMapping, final Session session) { Map<String, DatabaseField> map = databaseMapping.getAggregateToSourceFields(); if (!map.isEmpty()) { logFine(session, "Seems there where annotations for AttributeOverride"); return; } else { Class<?> referenceClass = databaseMapping.getReferenceClass(); Field[] fields = referenceClass.getDeclaredFields(); if (fields.length > 0) { for (Field f : fields) { String fieldName = f.getName(); DatabaseField databaseField = new DatabaseField(); String databaseFieldName = NameUtils.buildFieldName(tableName, fieldName); databaseField.setName(databaseFieldName); map.put(fieldName.toUpperCase(), databaseField); logFine(session, "\tAggregate-Field " + fieldName + " --> " + databaseFieldName); } } } }
/** * INTERNAL: * Flags that either this mapping or nested mapping is a JPA id mapping. */ public boolean isJPAIdNested(AbstractSession session) { if (isJPAId()) { return true; } else { ClassDescriptor referenceDescriptor = getReferenceDescriptor(); if (referenceDescriptor == null) { // the mapping has not been initialized yet referenceDescriptor = session.getDescriptor(getReferenceClass()); } for (DatabaseMapping mapping : referenceDescriptor.getMappings()) { if (mapping.isAggregateObjectMapping() && ((AggregateObjectMapping)mapping).isJPAIdNested(session)) { return true; } } return false; } }
/** * INTERNAL: * Flags that either this mapping or nested mapping is a JPA id mapping. */ public boolean isJPAIdNested(AbstractSession session) { if (isJPAId()) { return true; } else { ClassDescriptor referenceDescriptor = getReferenceDescriptor(); if (referenceDescriptor == null) { // the mapping has not been initialized yet referenceDescriptor = session.getDescriptor(getReferenceClass()); } for (DatabaseMapping mapping : referenceDescriptor.getMappings()) { if (mapping.isAggregateObjectMapping() && ((AggregateObjectMapping)mapping).isJPAIdNested(session)) { return true; } } return false; } }
/** * INTERNAL: * Indicates whether descriptor has at least one target foreign key mapping */ public boolean hasTargetForeignKeyMapping(AbstractSession session) { for (DatabaseMapping mapping: getMappings()) { if (mapping.isCollectionMapping() || (mapping.isObjectReferenceMapping() && !((ObjectReferenceMapping)mapping).isForeignKeyRelationship()) || mapping.isAbstractCompositeDirectCollectionMapping()) { return true; } else if (mapping.isAggregateObjectMapping()) { ClassDescriptor referenceDescriptor = ((AggregateObjectMapping)mapping).getReferenceDescriptor(); if (referenceDescriptor == null) { // the mapping has not been initialized yet referenceDescriptor = session.getDescriptor(((AggregateObjectMapping)mapping).getReferenceClass()); } if (referenceDescriptor.hasTargetForeignKeyMapping(session)) { return true; } } } return false; }
/** * INTERNAL: * Indicates whether descriptor has at least one target foreign key mapping */ public boolean hasTargetForeignKeyMapping(AbstractSession session) { for (DatabaseMapping mapping: getMappings()) { if (mapping.isCollectionMapping() || (mapping.isObjectReferenceMapping() && !((ObjectReferenceMapping)mapping).isForeignKeyRelationship()) || mapping.isAbstractCompositeDirectCollectionMapping()) { return true; } else if (mapping.isAggregateObjectMapping()) { ClassDescriptor referenceDescriptor = ((AggregateObjectMapping)mapping).getReferenceDescriptor(); if (referenceDescriptor == null) { // the mapping has not been initialized yet referenceDescriptor = session.getDescriptor(((AggregateObjectMapping)mapping).getReferenceClass()); } if (referenceDescriptor.hasTargetForeignKeyMapping(session)) { return true; } } } return false; }
Map<String, DatabaseField> mapping = m.getAggregateToSourceFields(); ClassDescriptor refDesc = descriptors.get(m.getReferenceClass()); for (DatabaseMapping refMapping : refDesc.getMappings()) { if (refMapping.isDirectToFieldMapping()) {
Object aggregateValue = mapping.getAttributeValueFromObject(object); while (readMappingFromQueryKey && mapping.isAggregateObjectMapping() && !((AggregateObjectMapping)mapping).getReferenceClass().equals(queryKey.getDescriptor().getJavaClass())) { mapping = mapping.getReferenceDescriptor().getObjectBuilder().getMappingForField(((DirectQueryKey)queryKey).getField()); aggregateValue = mapping.getRealAttributeValueFromObject(aggregateValue, session);
Object aggregateValue = mapping.getAttributeValueFromObject(object); while (readMappingFromQueryKey && mapping.isAggregateObjectMapping() && !((AggregateObjectMapping)mapping).getReferenceClass().equals(queryKey.getDescriptor().getJavaClass())) { mapping = mapping.getReferenceDescriptor().getObjectBuilder().getMappingForField(((DirectQueryKey)queryKey).getField()); aggregateValue = mapping.getRealAttributeValueFromObject(aggregateValue, session);
AbstractSession referenceSession = session; if( session.hasBroker()) { if (getReferenceClass() == null) { throw DescriptorException.referenceClassNotSpecified(this); referenceSession = session.getSessionForClass(getReferenceClass());
AbstractSession referenceSession = session; if( session.hasBroker()) { if (getReferenceClass() == null) { throw DescriptorException.referenceClassNotSpecified(this); referenceSession = session.getSessionForClass(getReferenceClass());
Object aggregateValue = mapping.getAttributeValueFromObject(object); while (readMappingFromQueryKey && mapping.isAggregateObjectMapping() && !((AggregateObjectMapping)mapping).getReferenceClass().equals(queryKey.getDescriptor().getJavaClass())) { mapping = mapping.getReferenceDescriptor().getObjectBuilder().getMappingForField(((DirectQueryKey)queryKey).getField()); aggregateValue = mapping.getRealAttributeValueFromObject(aggregateValue, session);