-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 
Author Message
 Post subject: Using Jasper Reports with Hibernate
PostPosted: Tue Feb 14, 2006 7:16 am 
Newbie

Joined: Tue Feb 14, 2006 7:10 am
Posts: 3
Hi,

I have seen a posting earlier in the site regarding Using Jasper Reports with Hibernate..and here is the wat the suggestion about how to create the reports using jasper and hibernate and convert it into pdf or any other formats.

List cats = session.find("from eg.Cat");

Map parameters = new HashMap();
parameters.put("Title", "The Cat Report");

InputStream reportStream = this.class.getResourceAsStream("/the-cat-report.xml");
JasperDesign jasperDesign = JasperManager.loadXmlDesign(reportStream);
JasperReport jasperReport = JasperManager.compileReport(jasperDesign);

JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(cats);
JasperPrint jasperPrint = JasperManager.fillReport(jasperReport, parameters, ds);

JasperManager.printReportToPdfFile(jasperPrint, "the-cat-report.pdf");

Now My doubt is HOW do i know wat kind of format is allowed in the the-cat-report.xml file mentioned in the code.

To be precise wat is the content in the xml file Is it a plain xml file or it has any mandatory tags in it.

Thanks in Advance,
Austin :-)

Link for the above mentioned posting is given below:

http://www.hibernate.org/79.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 14, 2006 6:49 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
This is a Jasper question rather than a Hibernate one but...

I have used Jasper reports extensivlely and it is straight forward to get it up and running. The lastest version has even better integration (which I am not using since I dont want to change 300 reports).

In anycase, the XML document (normally .jrxml extension) you refer to is the
defintion of the report. I suggest you use ireport to visually design the report and it will create you report definition for you.

See Jasper examples and ireport for further information.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 12:53 am 
Newbie

Joined: Tue Feb 14, 2006 7:10 am
Posts: 3
Hi David,

thank u for ur reply. At the same time i would also like to tel u that. I domt have any problem using the xml file whcih is used to create the design template. I would be using it any how.

Let me be more clear on wat i would like to say, If u see the examples or samples which are under the samples folder of JSR/demo/samples/noxmldesign/ this particular struture has been given for those who does nt want to use the designing tool or to be precise the .jrxml file.

I am ok with creating my own structure. But the problem i am facing is In the program u have to pass the query to fill the report.But i already have the data in the form of objects using Hibernate. Now if at all i pass on the query again..Does it mean that i am doing a repeatition of the code by executing the query twice.

Let me show us with example.

This part of the code is in jsr/demo/samples/noxmlDesign/noxmlDesignApp.java

//Query
JRDesignQuery query = new JRDesignQuery();
query.setText("SELECT * FROM Address $P!{OrderByClause}");
jasperDesign.setQuery(query);


Here is the click I dont want to send a query string again coz i have already got the queries data..i mean the result.

I hope u got my point.

Looking ahead for ur reply,

Austin


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 8:17 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I have not created reports without the jrxml defintion. I did not know you could do it. In anycase, the are multiple data sources that can be used. I use the POJO data source rather than pass the query or embed the query in the reports. eg;
Code:
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(cats);


This is the way I apporach it for my use cases.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 8:15 pm 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
JasperReports 1.2 now supports Hibernate directly. You can put a HQL query within the JRXML.

Sherman Wood
JasperSoft


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 10:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I was aware of the new enhancement but he wanted to know how to use POJOs. In anycase, thanks for dropping in. Good to see you monitor this forum.
Cheers.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 17, 2006 1:13 am 
Newbie

Joined: Tue Feb 14, 2006 7:10 am
Posts: 3
First of all Thanks to one and every one for ur help.

Is there any possiblity to check what is exactly happening or written inside the .jasper or .jrprint file once we pass on the parameters..like fill.

and comming back the original query i was still not able to figure out how it cud be done...with out repassing the query.

I go the data thru hibernate...now how shud i pass on the same data without requerying it or trying to rerteive the info from database.

//Query
JRDesignQuery query = new JRDesignQuery();
query.setText("SELECT * FROM Address $P!{OrderByClause}");
jasperDesign.setQuery(query);

I belive i am doing a repetetive work on this...Is there any possibility to skip this process...

Austin


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 17, 2006 11:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I don't use queries inside the report - my design choice. I would suggest you look at the latest version of Jasper and look at the example Hibernate sample suuplied. It uses HQL queries in the report.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 19, 2006 11:41 am 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
You really need to take these questions to the JasperReports forum http://sourceforge.net/forum/forum.php?forum_id=113530.

Setting the query like that will requery the data. David's mention of JRBeanCollectionDataSource points to the right way. Have a look at:


Code:
JasperFillManager

public static JasperPrint fillReport(JasperReport jasperReport,
      Map parameters,
      JRDataSource dataSource
      )


You can cache the dataSource, change the JasperReport and call the above method to get the result.


Sherman Wood
JasperSoft


Top
 Profile  
 
 Post subject: Re: Using Jasper Reports with Hibernate
PostPosted: Sat Sep 17, 2011 11:27 pm 
Newbie

Joined: Sat Sep 17, 2011 9:59 pm
Posts: 4
List cats = session.find("from eg.Cat");

Map parameters = new HashMap();
parameters.put("Title", "The Cat Report");

InputStream reportStream = this.class.getResourceAsStream("/the-cat-report.xml");
JasperDesign jasperDesign = JasperManager.loadXmlDesign(reportStream);
JasperReport jasperReport = JasperManager.compileReport(jasperDesign);

JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(cats);
JasperPrint jasperPrint = JasperManager.fillReport(jasperReport, parameters, ds);

JasperManager.printReportToPdfFile(jasperPrint, "the-cat-report.pdf");



// In this example JRBeanCollectionDataSource is used as a parameter instead of a resultset in SQL Query
in my case i did in JDBCODBC connection in ireports to create jrxml and the same query generated in ireports is passed in Hibrnate

Query q = HibHelper.getSession().createQuery(sql);

and passed this list to JRBeanCollectionDataSource

Will it works??????
and i always get a message that a particular column like login_name dosent exist


Top
 Profile  
 
 Post subject: Re: Using Jasper Reports with Hibernate
PostPosted: Mon Sep 26, 2011 10:35 am 
Newbie

Joined: Sat Sep 17, 2011 9:59 pm
Posts: 4
No..actually it didnt work,always get exceptions


Top
 Profile  
 
 Post subject: Re: Using Jasper Reports with Hibernate
PostPosted: Fri Oct 07, 2011 12:07 pm 
Newbie

Joined: Sat Sep 17, 2011 9:59 pm
Posts: 4
Can anyone help me to create jrxml in ireport using hibernate


Top
 Profile  
 
 Post subject: Re: Using Jasper Reports with Hibernate
PostPosted: Wed Jan 18, 2012 1:47 am 
Newbie

Joined: Wed Jan 18, 2012 1:35 am
Posts: 1
Its an interesting and useful thread of hibernate users. I think this forum contains plenty of nice information about hibernate. Thanks for sharing it with me.

_________________
Silk Dupioni Fabric | Vaastu | Silk Fabric | Silk Dupioni


Top
 Profile  
 
 Post subject: Re: Using Jasper Reports with Hibernate
PostPosted: Fri Apr 05, 2013 8:25 am 
Newbie

Joined: Fri Apr 05, 2013 8:08 am
Posts: 1
Hey Manjush, I am also looking for some help for create jrxml in ireport. I hope you got some way for making jrxml in this time. Pleas share some instruction.


Top
 Profile  
 
 Post subject: Re: Using Jasper Reports with Hibernate
PostPosted: Thu Apr 11, 2013 3:30 am 
Newbie

Joined: Thu Apr 11, 2013 2:29 am
Posts: 2
It may not working now~
you should ask for someone professional

_________________
http://www.arm2teeth.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.