private void ensureConversion(FieldDescriptorDef fieldDef, String checkLevel) throws ConstraintException
    {
        if (CHECKLEVEL_NONE.equals(checkLevel))
        {
            return;
        }

        // we issue a warning if we encounter a field with a java.util.Date java type without a conversion
        if ("java.util.Date".equals(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JAVA_TYPE)) &&
            !fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_CONVERSION))
        {
            LogHelper.warn(true,
                           FieldDescriptorConstraints.class,
                           "ensureConversion",
                           "The field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+
                               " of type java.util.Date is directly mapped to jdbc-type "+
                               fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE)+
                               ". However, most JDBC drivers can't handle java.util.Date directly so you might want to "+
                               " use a conversion for converting it to a JDBC datatype like TIMESTAMP.");
        }

        String conversionClass = fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_CONVERSION);

        if (((conversionClass == null) || (conversionClass.length() == 0)) &&
            fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_CONVERSION) &&
            fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_JDBC_TYPE).equals(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE)))
        {
            conversionClass = fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_CONVERSION);
            fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_CONVERSION, conversionClass);
        }
        // now checking
        if (CHECKLEVEL_STRICT.equals(checkLevel) && (conversionClass != null) && (conversionClass.length() > 0))
        {
            InheritanceHelper helper = new InheritanceHelper();

            try
            {
                if (!helper.isSameOrSubTypeOf(conversionClass, CONVERSION_INTERFACE))
                {
                    throw new ConstraintException("The conversion class specified for field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" does not implement the necessary interface "+CONVERSION_INTERFACE);
                }
            }
            catch (ClassNotFoundException ex)
            {
                throw new ConstraintException("The class "+ex.getMessage()+" hasn't been found on the classpath while checking the conversion class specified for field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName());
            }
        }
}
private void ensureConversion ( FieldDescriptorDef fieldDef , String checkLevel ) throws ConstraintException { if ( CHECKLEVEL_NONE . equals ( checkLevel ) ) { return ; } if ( "java.util.Date" . equals ( fieldDef . getProperty ( PropertyHelper . OJB_PROPERTY_JAVA_TYPE ) ) && ! fieldDef . hasProperty ( PropertyHelper . OJB_PROPERTY_CONVERSION ) ) { LogHelper . warn ( true , FieldDescriptorConstraints . class , "ensureConversion" , "The field " + fieldDef . getName ( ) + " in class " + fieldDef . getOwner ( ) . getName ( ) + " of type java.util.Date is directly mapped to jdbc-type " + fieldDef . getProperty ( PropertyHelper . OJB_PROPERTY_JDBC_TYPE ) + ". However, most JDBC drivers can't handle java.util.Date directly so you might want to " + " use a conversion for converting it to a JDBC datatype like TIMESTAMP." ) ; } String conversionClass = fieldDef . getProperty ( PropertyHelper . OJB_PROPERTY_CONVERSION ) ; if ( ( ( conversionClass == null ) || ( conversionClass . length ( ) == 0 ) ) && fieldDef . hasProperty ( PropertyHelper . OJB_PROPERTY_DEFAULT_CONVERSION ) && fieldDef . getProperty ( PropertyHelper . OJB_PROPERTY_DEFAULT_JDBC_TYPE ) . equals ( fieldDef . getProperty ( PropertyHelper . OJB_PROPERTY_JDBC_TYPE ) ) ) { conversionClass = fieldDef . getProperty ( PropertyHelper . OJB_PROPERTY_DEFAULT_CONVERSION ) ; fieldDef . setProperty ( PropertyHelper . OJB_PROPERTY_CONVERSION , conversionClass ) ; } if ( CHECKLEVEL_STRICT . equals ( checkLevel ) && ( conversionClass != null ) && ( conversionClass . length ( ) > 0 ) ) { InheritanceHelper helper = new InheritanceHelper ( ) ; try { if ( ! helper . isSameOrSubTypeOf ( conversionClass , CONVERSION_INTERFACE ) ) { throw new ConstraintException ( "The conversion class specified for field " + fieldDef . getName ( ) + " in class " + fieldDef . getOwner ( ) . getName ( ) + " does not implement the necessary interface " + CONVERSION_INTERFACE ) ; } } catch ( ClassNotFoundException ex ) { throw new ConstraintException ( "The class " + ex . getMessage ( ) + " hasn't been found on the classpath while checking the conversion class specified for field " + fieldDef . getName ( ) + " in class " + fieldDef . getOwner ( ) . getName ( ) ) ; } } }
Constraint that ensures that the field has a conversion if the java type requires it. Also checks the conversion class.

@param fieldDef   The field descriptor
@param checkLevel The current check level (this constraint is checked in basic (partly) and strict)
@exception ConstraintException If the conversion class is invalid