/** * PUBLIC: * Add a field translation that maps from a field in the * source table to a field name in the aggregate descriptor. */ public void addFieldTranslation(DatabaseField sourceField, String aggregateFieldName) { //AggregateObjectMapping does not seem to support Aggregates on multiple tables String unQualifiedAggregateFieldName = aggregateFieldName.substring(aggregateFieldName.lastIndexOf('.') + 1);// -1 is returned for no ".". getAggregateToSourceFields().put(unQualifiedAggregateFieldName, sourceField); }
/** * PUBLIC: * Add a field translation that maps from a field in the * source table to a field name in the aggregate descriptor. */ public void addFieldTranslation(DatabaseField sourceField, String aggregateFieldName) { //AggregateObjectMapping does not seem to support Aggregates on multiple tables String unQualifiedAggregateFieldName = aggregateFieldName.substring(aggregateFieldName.lastIndexOf('.') + 1);// -1 is returned for no ".". getAggregateToSourceFields().put(unQualifiedAggregateFieldName, sourceField); }
/** * INTERNAL: * Return a collection of the aggregate to source field associations. */ public Vector<Association> getAggregateToSourceFieldAssociations() { Vector<Association> associations = new Vector(getAggregateToSourceFields().size()); Iterator aggregateEnum = getAggregateToSourceFields().keySet().iterator(); Iterator sourceEnum = getAggregateToSourceFields().values().iterator(); while (aggregateEnum.hasNext()) { associations.addElement(new Association(aggregateEnum.next(), sourceEnum.next())); } return associations; }
/** * INTERNAL: * Return a collection of the aggregate to source field associations. */ public Vector<Association> getAggregateToSourceFieldAssociations() { Vector<Association> associations = new Vector(getAggregateToSourceFields().size()); Iterator aggregateEnum = getAggregateToSourceFields().keySet().iterator(); Iterator sourceEnum = getAggregateToSourceFields().values().iterator(); while (aggregateEnum.hasNext()) { associations.addElement(new Association(aggregateEnum.next(), sourceEnum.next())); } return associations; }
/** * INTERNAL: * Clone the aggregate to source field names. AggregateCollectionMapping * needs each nested embedded mapping to have its own list of aggregate * to source field names so that it can apply nested override names to * shared aggregate object mappings. */ @Override public Object clone() { AggregateObjectMapping mappingObject = (AggregateObjectMapping) super.clone(); Map<String, DatabaseField> aggregateToSourceFields = new HashMap<String, DatabaseField>(); aggregateToSourceFields.putAll(getAggregateToSourceFields()); mappingObject.setAggregateToSourceFields(aggregateToSourceFields); return mappingObject; }
protected void addAggregateObjectMappingLines(NonreflectiveMethodDefinition method, String mappingName, AggregateObjectMapping mapping) { if (mapping.getReferenceClassName() != null) { method.addLine(mappingName + ".setReferenceClass(" + mapping.getReferenceClassName() + ".class);"); } method.addLine(mappingName + ".setIsNullAllowed(" + mapping.isNullAllowed() + ");"); for (Iterator<String> fieldTranslationEnum = mapping.getAggregateToSourceFields().keySet().iterator(); fieldTranslationEnum.hasNext();) { String aggregateFieldName = fieldTranslationEnum.next(); DatabaseField sourceField = mapping.getAggregateToSourceFields().get(aggregateFieldName); //may need to account for delimiting on the sourceField in the future method.addLine(mappingName + ".addFieldNameTranslation(\"" + sourceField.getQualifiedName() + "\", \"" + aggregateFieldName + "\");"); } }
protected void addAggregateObjectMappingLines(NonreflectiveMethodDefinition method, String mappingName, AggregateObjectMapping mapping) { if (mapping.getReferenceClassName() != null) { method.addLine(mappingName + ".setReferenceClass(" + mapping.getReferenceClassName() + ".class);"); } method.addLine(mappingName + ".setIsNullAllowed(" + mapping.isNullAllowed() + ");"); for (Iterator<String> fieldTranslationEnum = mapping.getAggregateToSourceFields().keySet().iterator(); fieldTranslationEnum.hasNext();) { String aggregateFieldName = fieldTranslationEnum.next(); DatabaseField sourceField = mapping.getAggregateToSourceFields().get(aggregateFieldName); //may need to account for delimiting on the sourceField in the future method.addLine(mappingName + ".addFieldNameTranslation(\"" + sourceField.getQualifiedName() + "\", \"" + aggregateFieldName + "\");"); } }
/** * INTERNAL: * Clone the aggregate to source field names. AggregateCollectionMapping * needs each nested embedded mapping to have its own list of aggregate * to source field names so that it can apply nested override names to * shared aggregate object mappings. */ @Override public Object clone() { AggregateObjectMapping mappingObject = (AggregateObjectMapping) super.clone(); Map<String, DatabaseField> aggregateToSourceFields = new HashMap<String, DatabaseField>(); aggregateToSourceFields.putAll(getAggregateToSourceFields()); mappingObject.setAggregateToSourceFields(aggregateToSourceFields); Map<String, Object[]> nestedTranslations = new HashMap<String, Object[]>(); nestedTranslations.putAll(getNestedFieldTranslations()); mappingObject.setNestedFieldTranslations(nestedTranslations); return mappingObject; }
@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); } } } }
DatabaseField field = (DatabaseField)entry.next(); translateField(getAggregateToSourceFields().get(field.getName()), field, clonedDescriptor);
DatabaseField field = (DatabaseField)entry.next(); translateField(getAggregateToSourceFields().get(field.getName()), field, clonedDescriptor);
if (clonedDescriptor.hasTargetForeignKeyMapping(session) && !isJPAIdNested(session)) { for (DatabaseField pkField : getDescriptor().getPrimaryKeyFields()) { if (!getAggregateToSourceFields().containsKey(pkField.getName())) {
if (clonedDescriptor.hasTargetForeignKeyMapping(session) && !isJPAIdNested(session)) { for (DatabaseField pkField : getDescriptor().getPrimaryKeyFields()) { if (!getAggregateToSourceFields().containsKey(pkField.getName())) {
if (databaseMapping.isAggregateObjectMapping()) { AggregateObjectMapping m = (AggregateObjectMapping) databaseMapping; Map<String, DatabaseField> mapping = m.getAggregateToSourceFields();
if (nestedAggregateObjectMapping != null && nestedAggregateObjectMapping.getAggregateToSourceFields().containsKey(overrideField.getName())) { overrideField = nestedAggregateObjectMapping.getAggregateToSourceFields().get(overrideField.getName());