/** * Return a new direct/basic mapping for this type of descriptor. */ public AbstractDirectMapping newDirectMapping() { return new DirectToFieldMapping(); }
/** * Return a new direct/basic mapping for this type of descriptor. */ public AbstractDirectMapping newDirectMapping() { return new DirectToFieldMapping(); }
/** * 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) { DirectToFieldMapping mapping = new DirectToFieldMapping(); mapping.setAttributeName(attributeName); mapping.setFieldName(fieldName); return addMapping(mapping); }
/** * Allows {@link DirectToFieldMapping} (@Basic) mapping to be added to a * dynamic type through API. This method can be used on a new * {@link DynamicTypeImpl} that has yet to be added to a session and have * its descriptor initialized, or it can be called on an active * (initialized) descriptor. * <p> * There is no support currently for having the EclipseLink * {@link SchemaManager} generate ALTER TABLE calls so any new columns * expected must be added without the help of EclipseLink or use the * {@link SchemaManager#replaceObject(org.eclipse.persistence.tools.schemaframework.DatabaseObjectDefinition)} * to DROP and CREATE the table. WARNING: This will cause data loss. * * @param javaType * is the type of the attribute. If the type is a primitive it * will be converted to the comparable non-primitive type. */ public DirectToFieldMapping addDirectMapping(String name, Class<?> javaType, String fieldName) { DirectToFieldMapping mapping = new DirectToFieldMapping(); mapping.setAttributeName(name); mapping.setFieldName(fieldName); mapping.setAttributeClassification(javaType); return (DirectToFieldMapping) addMapping(mapping); }
/** * Allows {@link DirectToFieldMapping} (@Basic) mapping to be added to a * dynamic type through API. This method can be used on a new * {@link DynamicTypeImpl} that has yet to be added to a session and have * its descriptor initialized, or it can be called on an active * (initialized) descriptor. * <p> * There is no support currently for having the EclipseLink * {@link SchemaManager} generate ALTER TABLE calls so any new columns * expected must be added without the help of EclipseLink or use the * {@link SchemaManager#replaceObject(org.eclipse.persistence.tools.schemaframework.DatabaseObjectDefinition)} * to DROP and CREATE the table. WARNING: This will cause data loss. * * @param javaType * is the type of the attribute. If the type is a primitive it * will be converted to the comparable non-primitive type. */ public DirectToFieldMapping addDirectMapping(String name, Class<?> javaType, String fieldName) { DirectToFieldMapping mapping = new DirectToFieldMapping(); mapping.setAttributeName(name); mapping.setFieldName(fieldName); mapping.setAttributeClassification(javaType); return (DirectToFieldMapping) addMapping(mapping); }
/** * 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);; } }
/** * PUBLIC: * Add a direct to field mapping to the receiver. The new mapping specifies that * a variable accessed by the get and set methods of the class of objects which * the receiver describes maps in the default manner for its type to the indicated * database field. */ public DatabaseMapping addDirectMapping(String attributeName, String getMethodName, String setMethodName, String fieldName) { DirectToFieldMapping mapping = new DirectToFieldMapping(); mapping.setAttributeName(attributeName); mapping.setSetMethodName(setMethodName); mapping.setGetMethodName(getMethodName); mapping.setFieldName(fieldName); return addMapping(mapping); }
/** * 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);; } }
/** * Allows {@link DirectToFieldMapping} (@Basic) mapping to be added to a * dynamic type through API. This method can be used on a new * {@link DynamicTypeImpl} that has yet to be added to a session and have * its descriptor initialized, or it can be called on an active * (initialized) descriptor. * <p> * There is no support currently for having the EclipseLink * {@link SchemaManager} generate ALTER TABLE calls so any new columns * expected must be added without the help of EclipseLink or use the * {@link SchemaManager#replaceObject(org.eclipse.persistence.tools.schemaframework.DatabaseObjectDefinition)} * to DROP and CREATE the table. WARNING: This will cause data loss. * * @param javaType * is the type of the attribute. If the type is a primitive it * will be converted to the comparable non-primitive type. */ public DirectToFieldMapping addDirectMapping(String name, Class<?> javaType, String fieldName) { DirectToFieldMapping mapping = new DirectToFieldMapping(); mapping.setAttributeName(name); mapping.setFieldName(fieldName); mapping.setAttributeClassification(javaType); return (DirectToFieldMapping) addMapping(mapping); }
/** * INTERNAL: * Set the DatabaseField that will represent the key in a DirectMapMapping * @param keyField * @param descriptor */ public void setKeyField(DatabaseField keyField, ClassDescriptor descriptor){ if (keyMapping == null){ DirectToFieldMapping newKeyMapping = new DirectToFieldMapping(); newKeyMapping.setField(keyField); newKeyMapping.setDescriptor(descriptor); setKeyMapping(newKeyMapping); } if (((DatabaseMapping)keyMapping).isDirectToFieldMapping()){ ((DirectToFieldMapping)keyMapping).setField(keyField);; } }
/** * 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; }