arminw
Wed, 07 Nov 2007 16:38:03 -0800
Author: arminw Date: Wed Nov 7 16:37:40 2007 New Revision: 592978 URL: http://svn.apache.org/viewvc?rev=592978&view=rev Log: - fix problems caused by new OJB shortcut name support - disable automatic set of a FieldConversion for all array type fields (e.g. some DB support byte[] fields), log warning instead Modified: db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/OjbMemberTagsHandler.java db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/OjbTagsHandler.java db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ClassDescriptorConstraints.java db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/CollectionDescriptorConstraints.java db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/FieldDescriptorConstraints.java db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ReferenceDescriptorConstraints.java Modified: db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/OjbMemberTagsHandler.java URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/OjbMemberTagsHandler.java?rev=592978&r1=592977&r2=592978&view=diff ============================================================================== --- db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/OjbMemberTagsHandler.java (original) +++ db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/OjbMemberTagsHandler.java Wed Nov 7 16:37:40 2007 @@ -60,6 +60,25 @@ } /** + * Returns the name of the current member class. + * + * @return The member class name + * @exception XDocletException if an error occurs + */ + public static String getMemberClassName() throws XDocletException + { + if (getCurrentField() != null) { + return getCurrentField().getContainingClass().getQualifiedName(); + } + else if (getCurrentMethod() != null) { + return getCurrentMethod().getContainingClass().getQualifiedName(); + } + else { + return null; + } + } + + /** * Returns the type of the current member which is the type in the case of a field, the return type for a getter * method, or the type of the parameter for a setter method. * Modified: db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/OjbTagsHandler.java URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/OjbTagsHandler.java?rev=592978&r1=592977&r2=592978&view=diff ============================================================================== --- db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/OjbTagsHandler.java (original) +++ db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/OjbTagsHandler.java Wed Nov 7 16:37:40 2007 @@ -1781,7 +1781,12 @@ { if (OjbMemberTagsHandler.getMemberDimension() > 0) { - return JdbcTypeHelper.JDBC_DEFAULT_CONVERSION; + LogHelper.warn(true, OjbTagsHandler.class, "getDefaultJdbcConversionForCurrentMember", + "Class '" + OjbMemberTagsHandler.getMemberClassName() + + ", field '" + OjbMemberTagsHandler.getMemberName() + + "': Array type detected, a FieldConversion NEEDED?"); + //return JdbcTypeHelper.JDBC_DEFAULT_CONVERSION; + return null; } String type = OjbMemberTagsHandler.getMemberType().getQualifiedName(); Modified: db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ClassDescriptorConstraints.java URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ClassDescriptorConstraints.java?rev=592978&r1=592977&r2=592978&view=diff ============================================================================== --- db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ClassDescriptorConstraints.java (original) +++ db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ClassDescriptorConstraints.java Wed Nov 7 16:37:40 2007 @@ -458,7 +458,12 @@ } catch (ClassNotFoundException ex) { - throw new ConstraintException("Could not find the class "+ex.getMessage()+" on the classpath while checking the row-reader class "+rowReaderName+" of class "+classDef.getName()); + // throw new ConstraintException("Could not find the class "+ex.getMessage()+" on the classpath while checking the row-reader class "+rowReaderName+" of class "+classDef.getName()); + LogHelper.warn(true, + ClassDescriptorConstraints.class, + "checkRowReader", + "Class '" + classDef.getQualifiedName() + "', RowReader name '" + + rowReaderName + "' can't be resolved - SHORTCUT NAME or typo?"); } } @@ -501,7 +506,12 @@ } catch (ClassNotFoundException ex) { - throw new ConstraintException("Could not find the class "+ex.getMessage()+" on the classpath while checking the object-cache class "+objectCacheName+" of class "+classDef.getName()); + //throw new ConstraintException("Could not find the class "+ex.getMessage()+" on the classpath while checking the object-cache class "+objectCacheName+" of class "+classDef.getName()); + LogHelper.warn(true, + ClassDescriptorConstraints.class, + "checkObjectCache", + "Class '" + classDef.getQualifiedName() + "', ObjectCache name '" + + objectCacheName + "' can't be resolved - SHORTCUT NAME or typo?"); } } Modified: db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/CollectionDescriptorConstraints.java URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/CollectionDescriptorConstraints.java?rev=592978&r1=592977&r2=592978&view=diff ============================================================================== --- db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/CollectionDescriptorConstraints.java (original) +++ db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/CollectionDescriptorConstraints.java Wed Nov 7 16:37:40 2007 @@ -1,6 +1,7 @@ package xdoclet.modules.ojb.constraints; import xdoclet.modules.ojb.CommaListIterator; +import xdoclet.modules.ojb.LogHelper; import xdoclet.modules.ojb.model.ClassDescriptorDef; import xdoclet.modules.ojb.model.CollectionDescriptorDef; import xdoclet.modules.ojb.model.FieldDescriptorDef; @@ -217,7 +218,13 @@ } catch (ClassNotFoundException ex) { - throw new ConstraintException("Could not find the class "+ex.getMessage()+" on the classpath while checking the collection "+collDef.getName()+" in class "+collDef.getOwner().getName()); + // throw new ConstraintException("Could not find the class "+ex.getMessage()+" on the classpath while checking the collection "+collDef.getName()+" in class "+collDef.getOwner().getName()); + LogHelper.warn(true, + CollectionDescriptorConstraints.class, + "ensureCollectionClass", + "Class '" + collDef.getOwner().getName() + "', field '" + collDef.getName() + + "': Specified collection-class '" + specifiedClass + + "' can't be resolved - SHORTCUT NAME or typo?"); } } } Modified: db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/FieldDescriptorConstraints.java URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/FieldDescriptorConstraints.java?rev=592978&r1=592977&r2=592978&view=diff ============================================================================== --- db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/FieldDescriptorConstraints.java (original) +++ db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/FieldDescriptorConstraints.java Wed Nov 7 16:37:40 2007 @@ -1,12 +1,12 @@ package xdoclet.modules.ojb.constraints; import java.util.HashMap; +import java.util.Locale; import xdoclet.modules.ojb.LogHelper; import xdoclet.modules.ojb.model.FieldDescriptorDef; import xdoclet.modules.ojb.model.PropertyHelper; import xdoclet.modules.ojb.model.ClassDescriptorDef; -import org.apache.commons.lang.SystemUtils; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -71,6 +71,7 @@ _jdbcTypes.put("REF", null); _jdbcTypes.put("BOOLEAN", null); _jdbcTypes.put("DATALINK", null); + _jdbcTypes.put("JAVA_OBJECT", null); } /** @@ -165,10 +166,10 @@ } fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE, fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_JDBC_TYPE)); - if (!fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_CONVERSION) && fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_CONVERSION)) - { - fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_CONVERSION, fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_CONVERSION)); - } +// if (!fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_CONVERSION) && fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_CONVERSION)) +// { +// fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_CONVERSION, fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_CONVERSION)); +// } } else { @@ -178,13 +179,22 @@ if (!_jdbcTypes.containsKey(jdbcType)) { - throw new ConstraintException("The field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" specifies the invalid jdbc type "+jdbcType); + if(!_jdbcTypes.containsKey(jdbcType.toUpperCase(Locale.ENGLISH))) + { + throw new ConstraintException("The field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" specifies the invalid jdbc type "+jdbcType); + } + else + { + // replace with correct upper case + fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE, jdbcType.toUpperCase(Locale.ENGLISH)); + } } } } /** - * Constraint that ensures that the field has a conversion if the java type requires it. Also checks the conversion class. + * 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) @@ -234,7 +244,12 @@ } 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()); + //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()); + LogHelper.warn(true, + FieldDescriptorConstraints.class, + "ensureConversion", + "Class '"+fieldDef.getOwner().getName() + "', field '" + fieldDef.getName() + + "': FieldConversion class '" + conversionClass + "' can't be resolved - SHORTCUT NAME or typo?"); } } } Modified: db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ReferenceDescriptorConstraints.java URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ReferenceDescriptorConstraints.java?rev=592978&r1=592977&r2=592978&view=diff ============================================================================== --- db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ReferenceDescriptorConstraints.java (original) +++ db/ojb/branches/OJB_1_0_RELEASE/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ReferenceDescriptorConstraints.java Wed Nov 7 16:37:40 2007 @@ -122,10 +122,12 @@ { // no, so defer the check but issue a warning performCheck = false; - LogHelper.warn(true, - getClass(), - "ensureClassRef", - "Cannot check whether the type "+targetClassDef.getQualifiedName()+" specified as class-ref at reference "+refDef.getName()+" in class "+ownerClassDef.getName()+" is assignable to the declared type "+varType+" of the reference because this variable type cannot be found in source or on the classpath"); + LogHelper.warn(true, getClass(), "ensureClassRef", + "Cannot check whether the type " + targetClassDef.getQualifiedName() + + " specified as class-ref at reference " + refDef.getName() + + " in class "+ownerClassDef.getName() + + " is assignable to the declared type " + varType + + " of the reference because this variable type cannot be found in source or on the classpath"); } } if (performCheck && !helper.isSameOrSubTypeOf(targetClassDef, varType, true)) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]