Hi,

I think, I've found a bug in JAWS.

Custom finder methods, ie. those explicitly declared with <finder> in
jaws.xml, do not map their arguments according to the defined
type-mapping. Each argument is simply passed as Object to the JDBC
layer. This is different to the behavior of the auto-generated finders
like findByXX.

IMHO finders should have the same semantics, no matter they were
autogenerated or specified in jaws.xml.

Here is a patch to fix the problem:

Index: JDBCDefinedFinderCommand.java
===================================================================
RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/jaws/jdbc/JDBCDefinedFinderCommand.java,v
retrieving revision 1.9
diff -c -r1.9 JDBCDefinedFinderCommand.java
*** JDBCDefinedFinderCommand.java       2001/01/21 14:33:48     1.9
--- JDBCDefinedFinderCommand.java       2001/01/25 15:48:48
***************
*** 13,18 ****
--- 13,19 ----
  import java.sql.PreparedStatement;
  
  import org.jboss.ejb.plugins.jaws.metadata.FinderMetaData;
+ import org.jboss.ejb.plugins.jaws.metadata.TypeMappingMetaData;
  
  /**
   * JAWSPersistenceManager JDBCDefinedFinderCommand
***************
*** 30,35 ****
--- 31,37 ----
     // Attributes ----------------------------------------------------
     
     private int[] parameterArray;
+    private TypeMappingMetaData typeMapping;
     
     // Constructors --------------------------------------------------
     
***************
*** 37,42 ****
--- 39,46 ----
     {
        super(factory, f.getName());
        
+       typeMapping = jawsEntity.getJawsApplication().getTypeMapping();
+       
        // Replace placeholders with ?, but only if query is defined
        String query = "";
        ArrayList parameters = new ArrayList();
***************
*** 107,113 ****
        
        for (int i = 0; i < parameterArray.length; i++)
        {
!          stmt.setObject(i+1, args[parameterArray[i]]);
        }
     }
  }
--- 111,120 ----
        
        for (int i = 0; i < parameterArray.length; i++)
        {
!          Object arg = args[parameterArray[i]];
!          int jdbcType = typeMapping.getJdbcTypeForJavaType(arg.getClass());
! 
!          setParameter(stmt,i+1,jdbcType,arg);
        }
     }
  }


/Gabor

-- 
Gabor Herr                           [EMAIL PROTECTED]
Computer Science Department          [EMAIL PROTECTED]
Darmstadt University of Technology
Germany

Reply via email to