SQL查询不能在pentaho报表设计器中工作,而相同的查询在postgresql中工作正常

时间:2015-07-03 07:09:09

标签: postgresql pentaho

SQL查询在pentaho报表设计器中不起作用,而相同的查询在postgresql中正常工作。无法找出原因?

SELECT 
  product_product.default_code AS Sku,
  stock_inventory_line.product_qty AS Quantity
FROM 
  public.product_product, 
  public.product_template, 
  public.product_category, 
  public.stock_inventory_line
WHERE 
  product_product.product_tmpl_id = product_template.id AND
  product_template.categ_id = product_category.id AND
  stock_inventory_line.product_id = product_product.id AND
  product_category.name = 'Bboy'
 ORDER BY
  product_product.default_code ASC

当我尝试在pentaho报表设计器中运行它时,出现错误:

at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SimpleSQLReportDataFactory.queryData(SimpleSQLReportDataFactory.java:214)
    at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SQLReportDataFactory.queryData(SQLReportDataFactory.java:162)
    at org.pentaho.reporting.ui.datasources.jdbc.ui.JdbcPreviewWorker.run(JdbcPreviewWorker.java:95)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
    at org.postgresql.core.v3.SimpleParameterList.setNull(SimpleParameterList.java:137)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.setNull(AbstractJdbc2Statement.java:1215)
    at org.postgresql.jdbc3.AbstractJdbc3Statement.setNull(AbstractJdbc3Statement.java:1490)
    at org.postgresql.jdbc4.AbstractJdbc4Statement.setNull(AbstractJdbc4Statement.java:84)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:1874)
    at org.postgresql.jdbc3g.AbstractJdbc3gStatement.setObject(AbstractJdbc3gStatement.java:36)
    at org.postgresql.jdbc4.AbstractJdbc4Statement.setObject(AbstractJdbc4Statement.java:47)
    at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SimpleSQLReportDataFactory.parametrize(SimpleSQLReportDataFactory.java:418)
    at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SimpleSQLReportDataFactory.parametrizeAndQuery(SimpleSQLReportDataFactory.java:326)
    at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SimpleSQLReportDataFactory.queryData(SimpleSQLReportDataFactory.java:209)
    ... 3 more

2 个答案:

答案 0 :(得分:1)

试试这个查询,

SELECT 
  product_product.default_code AS Sku,
  stock_inventory_line.product_qty AS Quantity
FROM 
  public.product_product, 
  public.product_template, 
  public.product_category, 
  public.stock_inventory_line
WHERE 
  product_product.product_tmpl_id = product_template.id AND
  product_template.categ_id = product_category.id AND
  stock_inventory_line.product_id = product_product.id AND
  product_category.name = 'Bboy'
 ORDER BY
  1 ASC

答案 1 :(得分:0)

在Java应用程序中运行时遇到了同样的问题,下面的代码对我有用:

myReport.getDataFactory().initialize(new DesignTimeDataFactoryContext(myReport));
// your code...
TableModel myTable = myReport.getDataFactory().queryData(queryName, new ParameterDataRow());