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

℡╲_俬逩灬. 提交于 2019-12-24 13:06:35

问题


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())));

回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/22067965/what-is-this-error-and-how-do-i-prevent-this-the-bucket-expression-values-are-n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!