what is this error and how do I prevent this? The bucket expression values are not comparable and no comparator specified

StackOverflow https://stackoverflow.com//questions/22067965

Question

Im using jasperReports with dynamicReports and I want to build a crosstab report. so far I have figured out that this error happens when I add columns that are numeric to rowGroups or columnGroups. this is what I get and I don't know why and I don't know how to solve this.

The error is:

The bucket expression values are not comparable and no comparator specified

My code is:

    CrosstabValues crosstabValues = report.getCrosstab().getCrosstabValues();
    Collection<CrosstabRowGroupBuilder> rowGroup = generateRowGroup(crosstabValues);
    Collection<CrosstabColumnGroupBuilder> columnGroup = generateColumnGroup(crosstabValues);
    Collection<CrosstabMeasureBuilder> measures = generateMeasures(crosstabValues);

    CrosstabBuilder crosstab = ctab.crosstab();

    for(CrosstabRowGroupBuilder row : rowGroup)
        crosstab.addRowGroup(row);
    for(CrosstabColumnGroupBuilder columnGroupBuilder : columnGroup)
        crosstab.addColumnGroup(columnGroupBuilder);
    for(CrosstabMeasureBuilder measure : measures)
        crosstab.addMeasure(measure);

    crosstab.headerCell(cmp.text(crosstabValues.getHeader())
    .setStyle(getCrosstabHeaderCellStyle(report.getTemplate().getReportTemplateValues())));
Was it helpful?

Solution

the problem was the class I was giving to this method:

CrosstabRowGroupBuilder cTabRow = ctab.rowGroup(column.getName()
, getColumnTypeClass(column));

i was using Number class for all numeric data. the funny thing is that it worked for measures but it did not work for rowGroup or columnGroup. that is why I got confused.

now with Integer.Class or Long.Class it works good.

OTHER TIPS

Crosstab must know in which order display rowHeader or columnHeader. And crosstab must know in which cell of crosstab put measure. It is possible only if crosstab is able compare rowGroup (and ColumnGroup) values.

Classes which used in rowGroup and columnGroup must implements Comparable interface

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top