/** * INTERNAL: * Return the fields that make up the identity of the mapped object. For mappings with * a primary key, it will be the set of fields in the primary key. For mappings without * a primary key it will likely be all the fields * @return */ public List<DatabaseField> getIdentityFieldsForMapKey(){ return getForeignKeyFields(); }
/** * INTERNAL: * Return the fields that make up the identity of the mapped object. For mappings with * a primary key, it will be the set of fields in the primary key. For mappings without * a primary key it will likely be all the fields * @return */ public List<DatabaseField> getIdentityFieldsForMapKey(){ return getForeignKeyFields(); }
/** * INTERNAL: * Return the fields that make up the identity of the mapped object. For mappings with * a primary key, it will be the set of fields in the primary key. For mappings without * a primary key it will likely be all the fields * @return */ public List<DatabaseField> getIdentityFieldsForMapKey(){ return getForeignKeyFields(); }
/** * PUBLIC: * Return the foreign key field names associated with the mapping. * These are only the source fields that are writable. */ public Vector getForeignKeyFieldNames() { Vector fieldNames = new Vector(getForeignKeyFields().size()); for (Enumeration fieldsEnum = getForeignKeyFields().elements(); fieldsEnum.hasMoreElements();) { fieldNames.addElement(((DatabaseField)fieldsEnum.nextElement()).getQualifiedName()); } return fieldNames; }
/** * PUBLIC: * Return the foreign key field names associated with the mapping. * These are only the source fields that are writable. */ public Vector getForeignKeyFieldNames() { Vector fieldNames = new Vector(getForeignKeyFields().size()); for (Enumeration fieldsEnum = getForeignKeyFields().elements(); fieldsEnum.hasMoreElements();) { fieldNames.addElement(((DatabaseField)fieldsEnum.nextElement()).getQualifiedName()); } return fieldNames; }
/** * PUBLIC: * Return the foreign key field names associated with the mapping. * These are only the source fields that are writable. */ public Vector getForeignKeyFieldNames() { Vector fieldNames = new Vector(getForeignKeyFields().size()); for (Enumeration fieldsEnum = getForeignKeyFields().elements(); fieldsEnum.hasMoreElements();) { fieldNames.addElement(((DatabaseField)fieldsEnum.nextElement()).getQualifiedName()); } return fieldNames; }
/** * INTERNAL: * Used when initializing queries for mappings that use a Map * Called when the insert query is being initialized to ensure the fields for the map key are in the insert query */ public void addFieldsForMapKey(AbstractRecord joinRow){ Iterator i = getForeignKeyFields().iterator(); while (i.hasNext()){ joinRow.put((DatabaseField)i.next(), null); } }
/** * INTERNAL: * Used when initializing queries for mappings that use a Map * Called when the insert query is being initialized to ensure the fields for the map key are in the insert query */ public void addFieldsForMapKey(AbstractRecord joinRow){ Iterator i = getForeignKeyFields().iterator(); while (i.hasNext()){ joinRow.put((DatabaseField)i.next(), null); } }
/** * INTERNAL: * Used when initializing queries for mappings that use a Map * Called when the insert query is being initialized to ensure the fields for the map key are in the insert query */ public void addFieldsForMapKey(AbstractRecord joinRow){ Iterator i = getForeignKeyFields().iterator(); while (i.hasNext()){ joinRow.put((DatabaseField)i.next(), null); } }
/** * INTERNAL: * Get all the fields for the map key */ public List<DatabaseField> getAllFieldsForMapKey(){ List<DatabaseField> fields = new ArrayList(getReferenceDescriptor().getAllFields().size() + getForeignKeyFields().size()); fields.addAll(getReferenceDescriptor().getAllFields()); fields.addAll(getForeignKeyFields()); return fields; }
/** * INTERNAL: * Get all the fields for the map key */ public List<DatabaseField> getAllFieldsForMapKey(){ List<DatabaseField> fields = new ArrayList(getReferenceDescriptor().getAllSelectionFields().size() + getForeignKeyFields().size()); fields.addAll(getReferenceDescriptor().getAllSelectionFields()); fields.addAll(getForeignKeyFields()); return fields; }
/** * INTERNAL: * Get all the fields for the map key */ public List<DatabaseField> getAllFieldsForMapKey(){ List<DatabaseField> fields = new ArrayList(getReferenceDescriptor().getAllSelectionFields().size() + getForeignKeyFields().size()); fields.addAll(getReferenceDescriptor().getAllSelectionFields()); fields.addAll(getForeignKeyFields()); return fields; }
/** * INTERNAL: * Extract the fields for the Map key from the object to use in a query */ public Map extractIdentityFieldsForQuery(Object object, AbstractSession session){ Map keyFields = new HashMap(); for (int index = 0; index < getForeignKeyFields().size(); index++) { DatabaseField targetRelationField = getForeignKeyFields().elementAt(index); DatabaseField targetKey = getSourceToTargetKeyFields().get(targetRelationField); Object value = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(object, targetKey, session); keyFields.put(targetRelationField, value); } return keyFields; }
/** * INTERNAL: * Extract the fields for the Map key from the object to use in a query */ public Map extractIdentityFieldsForQuery(Object object, AbstractSession session){ Map keyFields = new HashMap(); for (int index = 0; index < getForeignKeyFields().size(); index++) { DatabaseField targetRelationField = getForeignKeyFields().elementAt(index); DatabaseField targetKey = getSourceToTargetKeyFields().get(targetRelationField); Object value = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(object, targetKey, session); keyFields.put(targetRelationField, value); } return keyFields; }
/** * INTERNAL: * Extract the fields for the Map key from the object to use in a query * @return */ public Map extractIdentityFieldsForQuery(Object object, AbstractSession session){ Map keyFields = new HashMap(); for (int index = 0; index < getForeignKeyFields().size(); index++) { DatabaseField targetRelationField = getForeignKeyFields().elementAt(index); DatabaseField targetKey = getSourceToTargetKeyFields().get(targetRelationField); Object value = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(object, targetKey, session); keyFields.put(targetRelationField, value); } return keyFields; }
/** * INTERNAL: * Write fields needed for insert into the template for with null values. */ public void writeInsertFieldsIntoRow(AbstractRecord databaseRow, AbstractSession session) { if (isReadOnly() || (!isForeignKeyRelationship())) { return; } for (Enumeration fieldsEnum = getForeignKeyFields().elements(); fieldsEnum.hasMoreElements();) { DatabaseField sourceKey = (DatabaseField)fieldsEnum.nextElement(); databaseRow.add(sourceKey, null); } }
/** * INTERNAL: * This row is built for shallow insert which happens in case of bidirectional inserts. * The foreign keys must be set to null to avoid constraints. */ public void writeFromObjectIntoRowForShallowInsert(Object object, AbstractRecord databaseRow, AbstractSession session) { if (isReadOnly() || (!isForeignKeyRelationship())) { return; } for (Enumeration fieldsEnum = getForeignKeyFields().elements(); fieldsEnum.hasMoreElements();) { DatabaseField sourceKey = (DatabaseField)fieldsEnum.nextElement(); databaseRow.add(sourceKey, null); } }
protected void addOneToOneMappingLines(NonreflectiveMethodDefinition method, String mappingName, OneToOneMapping mapping) { for (Iterator foreignKeysEnum = mapping.getSourceToTargetKeyFields().keySet().iterator(); foreignKeysEnum.hasNext();) { DatabaseField sourceField = (DatabaseField)foreignKeysEnum.next(); DatabaseField targetField = mapping.getSourceToTargetKeyFields().get(sourceField); if (mapping.getForeignKeyFields().contains(sourceField)) { method.addLine(mappingName + ".addForeignKeyFieldName(\"" + sourceField.getQualifiedName() + "\", \"" + targetField.getQualifiedName() + "\");"); } else { method.addLine(mappingName + ".addTargetForeignKeyFieldName(\"" + targetField.getQualifiedName() + "\", \"" + sourceField.getQualifiedName() + "\");"); } } if (!mapping.shouldVerifyDelete()) { method.addLine(mappingName + ".setShouldVerifyDelete(false);"); } }
/** * INTERNAL: * Used when initializing queries for mappings that use a Map. * Called when the selection query is being initialized to add the fields for the map key to the query. */ public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression){ for (DatabaseField field : getForeignKeyFields()) { if (selectionQuery.isObjectLevelReadQuery()){ ((ObjectLevelReadQuery)selectionQuery).addAdditionalField(baseExpression.getField(field)); } else if (selectionQuery.isDataReadQuery()){ ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField(field); } } }
/** * INTERNAL: * Used when initializing queries for mappings that use a Map. * Called when the selection query is being initialized to add the fields for the map key to the query. */ public void addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression){ for (DatabaseField field : getForeignKeyFields()) { if (selectionQuery.isObjectLevelReadQuery()){ ((ObjectLevelReadQuery)selectionQuery).addAdditionalField(baseExpression.getField(field)); } else if (selectionQuery.isDataReadQuery()){ ((SQLSelectStatement)((DataReadQuery)selectionQuery).getSQLStatement()).addField(field); } } }