private void ensurePrecisionAndScale ( FieldDescriptorDef fieldDef , String checkLevel ) { fieldDef . setProperty ( PropertyHelper . OJB_PROPERTY_DEFAULT_PRECISION , null ) ; fieldDef . setProperty ( PropertyHelper . OJB_PROPERTY_DEFAULT_SCALE , null ) ; if ( ! fieldDef . hasProperty ( PropertyHelper . OJB_PROPERTY_PRECISION ) ) { String defaultPrecision = JdbcTypeHelper . getDefaultPrecisionFor ( fieldDef . getProperty ( PropertyHelper . OJB_PROPERTY_JDBC_TYPE ) ) ; if ( defaultPrecision != null ) { LogHelper . warn ( true , FieldDescriptorConstraints . class , "ensureLength" , "The field " + fieldDef . getName ( ) + " in class " + fieldDef . getOwner ( ) . getName ( ) + " has no precision setting though its jdbc type requires it (in most databases); using default precision of " + defaultPrecision ) ; fieldDef . setProperty ( PropertyHelper . OJB_PROPERTY_DEFAULT_PRECISION , defaultPrecision ) ; } else if ( fieldDef . hasProperty ( PropertyHelper . OJB_PROPERTY_SCALE ) ) { fieldDef . setProperty ( PropertyHelper . OJB_PROPERTY_DEFAULT_PRECISION , "1" ) ; } } if ( ! fieldDef . hasProperty ( PropertyHelper . OJB_PROPERTY_SCALE ) ) { String defaultScale = JdbcTypeHelper . getDefaultScaleFor ( fieldDef . getProperty ( PropertyHelper . OJB_PROPERTY_JDBC_TYPE ) ) ; if ( defaultScale != null ) { LogHelper . warn ( true , FieldDescriptorConstraints . class , "ensureLength" , "The field " + fieldDef . getName ( ) + " in class " + fieldDef . getOwner ( ) . getName ( ) + " has no scale setting though its jdbc type requires it (in most databases); using default scale of " + defaultScale ) ; fieldDef . setProperty ( PropertyHelper . OJB_PROPERTY_DEFAULT_SCALE , defaultScale ) ; } else if ( fieldDef . hasProperty ( PropertyHelper . OJB_PROPERTY_PRECISION ) || fieldDef . hasProperty ( PropertyHelper . OJB_PROPERTY_DEFAULT_PRECISION ) ) { fieldDef . setProperty ( PropertyHelper . OJB_PROPERTY_DEFAULT_SCALE , "0" ) ; } } }
Constraint that ensures that the field has precision and scale settings if the jdbc type requires it .