Jump to content
We've recently updated our Privacy Statement, available here ×

Problem with query


Recommended Posts

By: Dices Almighty - dices

Problem with query

2006-03-10 10:56

Any other information needed please ask.

When i try to run the report i get this problem

 

tried with joins and selects but i get the same problem

 

from Notary n join n.notaryAddress a where n.id = $P{notaryID} and a.id = n.notaryAddress

 

 

 

Error filling print...

Hibernate session opened Hibernate session closed net.sf.jasperreports.engine.JRRuntimeException: Unknown HQL return alias "notaryAddress". at net.sf.jasperreports.engine.data.JRHibernateAbstractDataSource.getFieldReader(JRHibernateAbstractDataSource.java:189) at net.sf.jasperreports.engine.data.JRHibernateAbstractDataSource.assignReaders(JRHibernateAbstractDataSource.java:132) at net.sf.jasperreports.engine.data.JRHibernateAbstractDataSource.<init>(JRHibernateAbstractDataSource.java:69) at net.sf.jasperreports.engine.data.JRHibernateListDataSource.<init>(JRHibernateListDataSource.java:55) at net.sf.jasperreports.engine.query.JRHibernateQueryExecuter.createResultDatasource(JRHibernateQueryExecuter.java:160) at net.sf.jasperreports.engine.query.JRHibernateQueryExecuter.createDatasource(JRHibernateQueryExecuter.java:129) at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:632) at net.sf.jasperreports.engine.fill.JRFillDataset.setDatasource(JRFillDataset.java:576) at net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:565) at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:847) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:672) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:123) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:420) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:256) at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:701) at java.lang.Thread.run(Thread.java:595)

Print not filled. Try to use an EmptyDataSource...!

 

 

 

 

By: Lucian Chirita - lucianc

RE: Problem with query

2006-03-13 02:52

When a Hibernate query returns multiple objects/scalar values, the JR Hibernate data source uses aliases to map fields to result values.

 

In your case, the query returns two objects (because of the join) but you don't have any return aliases. Therefore, the data source does not know how to map values to the report fields.

 

What you couild do is this:

"select n as notary, a as address from Notary n join n.notaryAddress a where n.id = $P{notaryID}"

and then map fields using expressions like "notary.field" or "address.field".

 

There are other possibilies also, you should chose the one that best suits your needs.

 

HTH,

Lucian

Link to comment
Share on other sites

  • 1 month later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Hi.

 

I think it would be useful for ireport to automatically propose an alias ( like the name of the class) so that the user becomes aware of this problem ( I just lost some time with this before I found this post).

 

Another thing which did cost me some time was: when you use the report wizard and put an HQL query ( supposing the default datasource is hibernate) - the query is not configured as HQL, it's SQL by default and the report can't execute.

 

Thank you,

Tudor

Link to comment
Share on other sites

I'm not exactly an iReport expert, but this is how I see it.

 

How do you think iReport would automatically propose aliases? Should iReport feature some kind of editing enhancement that inserts aliases while the user types the HQL query? This seems very difficult to achieve, iReport should know how to parse partial HQL queries. A simpler to implement approach would be to verify the query and issue some warnings if aliases are not specified..

 

The second issue looks like a iReport bug. If it's reproducible in the latest version, you should log it here.

 

This should have been probably posted on the iReport forum..

 

 

Regards,

Lucian

Post edited by: lucianc, at: 2006/10/20 09:18

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...