Jump to content
  • Array parameter not producing correct number of SQL placeholders


    lmclean
    Assigned User lucianc
    CategoryBug report
    PriorityNormal
    ReproducibilityAlways
    ResolutionFixed
    SeverityMinor
    StatusClosed

    Precondition:

    JasperReports 4.1.2

    The same issue seemed to be produced on each public version from 4.0.1 to 4.1.2

     

    Trigger:

    Create a report that uses $X{IN, col, param} and make sure the parameter being used is an array with more than one element.

     

    Symptom:

    Only one ? will be added to the SQL for this clause. It will then attempt to set values on the PreparedStatement for each element in the array. This will fail as there are more values than parameter placeholders.

     

    Root Cause:

    In net.sf.jasperreports.engine.query.JRSqlAbstractInClause, the convert method is using Arrays.asList to take the array and produce a Collection. The resulting Collection only has one element, the source array.

     

    Solution:

    Cast the Object parameter to an Object[]

    from...

    if( paramValue.getClass().isArray() ) {

    paramCollection = Arrays.asList( paramValue );

    }

    to...

    if( paramValue.getClass().isArray() ) {

    paramCollection = Arrays.asList( (Object[])paramValue );

    }

    In version 4.1.2, the significant line number is 234.



    User Feedback

    Recommended Comments

    This is a regression introduced in JR 4.0.1.

     

    Fixed in the SVN trunk:

    Sending /home/lucian/work/jasperreports/src/net/sf/jasperreports/engine/query/JRSqlAbstractInClause.java

    Transmitting file data ...

    Committed revision 4643.

     

    Regards,

    Lucian

    Link to comment
    Share on other sites


×
×
  • Create New...