/** * Indicates if the mapping has a converter set on it. * * @return true if there is a converter set on the mapping, * false otherwise. */ public boolean hasConverter() { return getConverter() != null; }
/** * INTERNAL: * Get the Converter for the key of this mapping if one exists. */ public Converter getKeyConverter() { if ((keyMapping != null) && ((DatabaseMapping)keyMapping).isDirectToFieldMapping()) { return ((AbstractDirectMapping)keyMapping).getConverter(); } return null; }
/** * INTERNAL: * Get the Converter for the key of this mapping if one exists. */ public Converter getKeyConverter() { if ((keyMapping != null) && ((DatabaseMapping)keyMapping).isDirectToFieldMapping()) { return ((AbstractDirectMapping)keyMapping).getConverter(); } return null; }
/** * INTERNAL: * Extract the fields for the Map key from the object to use in a query. */ public Map extractIdentityFieldsForQuery(Object object, AbstractSession session){ Map fields = new HashMap(); Object key = object; if (getConverter() != null){ key = getConverter().convertObjectValueToDataValue(key , session); } fields.put(getField(), key); 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 fields = new HashMap(); Object key = object; if (getConverter() != null){ key = getConverter().convertObjectValueToDataValue(key , session); } fields.put(getField(), key); return fields; }
/** * 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 fields = new HashMap(); Object key = object; if (getConverter() != null){ key = getConverter().convertObjectValueToDataValue(key , session); } fields.put(getField(), key); return fields; }
public Enum getEnum() { EnumTypeConverter converter = (EnumTypeConverter)adm.getConverter(); converter.convertClassNamesToClasses(dcl); Class enumClass = converter.getEnumClass(); String literalLabel = (String)converter.getAttributeToFieldValues(). keySet().iterator().next(); return Enum.valueOf(enumClass, literalLabel); } }
public Enum getEnum() { EnumTypeConverter converter = (EnumTypeConverter)adm.getConverter(); converter.convertClassNamesToClasses(dcl); Class enumClass = converter.getEnumClass(); String literalLabel = (String)converter.getAttributeToFieldValues(). keySet().iterator().next(); return Enum.valueOf(enumClass, literalLabel); } }
public void addEnumLiteral(String literalLabel) { dcl.addEnum(className, literalLabel); EnumTypeConverter converter = (EnumTypeConverter)adm.getConverter(); converter.addConversionValue(literalLabel, literalLabel); }
public void addEnumLiteral(String literalLabel) { dcl.addEnum(className, literalLabel); EnumTypeConverter converter = (EnumTypeConverter)adm.getConverter(); converter.addConversionValue(literalLabel, literalLabel); }
/** * INTERNAL: * Initialize the attribute classification. * @Throws DescriptorException when attributeClassification is null */ public void preInitialize(AbstractSession session) throws DescriptorException { super.preInitialize(session); // Allow the attribute class to be set by the user. if (this.attributeClassification == null) { this.attributeClassification = getAttributeAccessor().getAttributeClass(); } this.attributeObjectClassification = Helper.getObjectClass(this.attributeClassification); // Initialize isMutable if not specified, default is false (assumes not mutable). if (this.isMutable == null) { if (getConverter() != null) { setIsMutable(getConverter().isMutable()); } else { setIsMutable(false); } // If mapping a temporal type, use the project mutable default. if (ClassConstants.UTILDATE.isAssignableFrom(getAttributeClassification()) || ClassConstants.CALENDAR.isAssignableFrom(getAttributeClassification())) { setIsMutable(session.getProject().getDefaultTemporalMutable()); } } }
/** * INTERNAL: * Initialize the attribute classification. */ @Override public void preInitialize(AbstractSession session) throws DescriptorException { super.preInitialize(session); // Allow the attribute class to be set by the user. if (this.attributeClassification == null) { this.attributeClassification = getAttributeAccessor().getAttributeClass(); } this.attributeObjectClassification = Helper.getObjectClass(this.attributeClassification); // Initialize isMutable if not specified, default is false (assumes not mutable). if (this.isMutable == null) { if (hasConverter()) { setIsMutable(getConverter().isMutable()); } else { setIsMutable(false); } // If mapping a temporal type, use the project mutable default. if ((getAttributeClassification() != null) && (ClassConstants.UTILDATE.isAssignableFrom(getAttributeClassification()) || ClassConstants.CALENDAR.isAssignableFrom(getAttributeClassification()))) { setIsMutable(session.getProject().getDefaultTemporalMutable()); } } Map nullValues = session.getPlatform(this.descriptor.getJavaClass()).getConversionManager().getDefaultNullValues(); bypassDefaultNullValueCheck = (!this.attributeClassification.isPrimitive()) && ((nullValues == null) || (!nullValues.containsKey(this.attributeClassification))); }
setIsMutable(getConverter().isMutable()); } else { setIsMutable(false);
/** * 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); } }
method.addLine(mappingName + ".setNullValue(" + printString(directMapping.getNullValue()) + ");"); Converter converter = directMapping.getConverter(); if (converter != null) { addConverterLines(method, mappingName + "Converter", converter);
method.addLine(mappingName + ".setNullValue(" + printString(directMapping.getNullValue()) + ");"); Converter converter = directMapping.getConverter(); if (converter != null) { addConverterLines(method, mappingName + "Converter", converter);
method.addLine(mappingName + ".setNullValue(" + printString(directMapping.getNullValue()) + ");"); Converter converter = directMapping.getConverter(); if (converter != null) { addConverterLines(method, mappingName + "Converter", converter);
getConverter().initialize(this, session);
getConverter().initialize(this, session);