/** * INTERNAL: * Set the DatabaseField that will represent the key in a DirectMapMapping. */ public void setKeyField(DatabaseField keyField, ClassDescriptor descriptor) { if (keyMapping == null) { AbstractDirectMapping newKeyMapping = new DirectToFieldMapping(); newKeyMapping.setField(keyField); newKeyMapping.setDescriptor(descriptor); setKeyMapping(newKeyMapping); } if (((DatabaseMapping)keyMapping).isDirectToFieldMapping()) { ((AbstractDirectMapping)keyMapping).setField(keyField);; } }
/** * INTERNAL: * The mapping is initialized with the given session. * This mapping is fully initialized after this. */ public void initialize(AbstractSession session) throws DescriptorException { super.initialize(session); if (getField() == null) { session.getIntegrityChecker().handleError(DescriptorException.fieldNameNotSetInMapping(this)); } if (keyTableForMapKey == null){ setField(getDescriptor().buildField(getField())); } else { setField(getDescriptor().buildField(getField(), keyTableForMapKey)); } setFields(collectFields()); if (getConverter() != null) { getConverter().initialize(this, session); } // Must unwrap Struct types on WLS. if (getField().getSqlType() == java.sql.Types.STRUCT) { getDescriptor().setIsNativeConnectionRequired(true); } }
/** * INTERNAL: * Set the DatabaseField that will represent the key in a DirectMapMapping. */ public void setKeyField(DatabaseField keyField, ClassDescriptor descriptor) { if (keyMapping == null) { AbstractDirectMapping newKeyMapping = new DirectToFieldMapping(); newKeyMapping.setField(keyField); newKeyMapping.setDescriptor(descriptor); setKeyMapping(newKeyMapping); } if (((DatabaseMapping)keyMapping).isDirectToFieldMapping()) { ((AbstractDirectMapping)keyMapping).setField(keyField);; } }
/** * INTERNAL: * The mapping clones itself to create deep copy. */ @Override public Object clone() { AbstractDirectMapping clone = (AbstractDirectMapping)super.clone(); // Field must be cloned so aggregates do not share fields. clone.setField(getField().clone()); return clone; }
/** * INTERNAL: * The mapping clones itself to create deep copy. */ @Override public Object clone() { AbstractDirectMapping clone = (AbstractDirectMapping)super.clone(); // Field must be cloned so aggregates do not share fields. clone.setField(getField().clone()); return clone; }
/** * INTERNAL: * The mapping clones itself to create deep copy. */ public Object clone() { AbstractDirectMapping clone = (AbstractDirectMapping)super.clone(); // Field must be cloned so aggregates do not share fields. clone.setField((DatabaseField)getField().clone()); return clone; }
/** * PUBLIC: * Add a direct to field mapping to the receiver. The new mapping specifies that * an instance variable of the class of objects which the receiver describes maps in * the default manner for its type to the indicated database field. * * @param attributeName is the name of an instance variable of the * class which the receiver describes. * @param fieldName is the name of the database column which corresponds * with the designated instance variable. * @return The newly created DatabaseMapping is returned. */ public DatabaseMapping addDirectMapping(String attributeName, String fieldName) { AbstractDirectMapping mapping = newDirectMapping(); mapping.setAttributeName(attributeName); mapping.setField(new DatabaseField(fieldName)); return addMapping(mapping); }
/** * PUBLIC: * Add a direct to field mapping to the receiver. The new mapping specifies that * an instance variable of the class of objects which the receiver describes maps in * the default manner for its type to the indicated database field. * * @param attributeName is the name of an instance variable of the * class which the receiver describes. * @param fieldName is the name of the database column which corresponds * with the designated instance variable. * @return The newly created DatabaseMapping is returned. */ public DatabaseMapping addDirectMapping(String attributeName, String fieldName) { AbstractDirectMapping mapping = newDirectMapping(); mapping.setAttributeName(attributeName); mapping.setField(new DatabaseField(fieldName)); return addMapping(mapping); }
((AbstractDirectMapping) idMapping).setField(foreignKeyField);
/** * INTERNAL: */ protected AbstractDirectMapping processDirectMapKeyClass(MappedKeyMapAccessor mappedKeyMapAccessor) { AbstractDirectMapping keyMapping = new DirectToFieldMapping(); // Get the map key field, defaulting and looking for attribute // overrides. Set the field before applying a converter. DatabaseField mapKeyField = getDatabaseField(getReferenceDatabaseTable(), MetadataLogger.MAP_KEY_COLUMN); keyMapping.setField(mapKeyField); keyMapping.setIsReadOnly(mapKeyField.isReadOnly()); keyMapping.setAttributeClassificationName(mappedKeyMapAccessor.getMapKeyClass().getName()); keyMapping.setDescriptor(getDescriptor().getClassDescriptor()); // Process a convert key or jpa converter for the map key if specified. processMappingKeyConverter(keyMapping, mappedKeyMapAccessor.getMapKeyConvert(), mappedKeyMapAccessor.getMapKeyConverts(), mappedKeyMapAccessor.getMapKeyClass(), mappedKeyMapAccessor.getMapKeyClassWithGenerics()); return keyMapping; }
mapping.setField(m_databaseField); mapping.setIsReadOnly(m_databaseField.isReadOnly()); mapping.setAttributeName(getAttributeName());