File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes ireport generated report breaks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "ireport generated report breaks" Watch "ireport generated report breaks" New topic
Author

ireport generated report breaks

kalyen kumar
Ranch Hand

Joined: Sep 18, 2008
Posts: 53
Hi,

I am new to iReport 3.5.0.
I created a sample report by connecting to my MS SQL SERVER DB.
But the problem is whenever there is change in column name of a table in my DB, the report breaks.

QUESTION: What should I do to decouple the report from my DB so that my DB changes wont break my report.

Thanks in advance,
Kalyen
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

How/why does it break?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Gerardo Tasistro
Ranch Hand

Joined: Feb 08, 2005
Posts: 362
Pass it a bean. Use beans as source rather than raw SQL. That will decouple your report logic from the data access logic.
kalyen kumar
Ranch Hand

Joined: Sep 18, 2008
Posts: 53
So using using Hibernate in my application answers this question...?

Here is another discussion of my question

http://jasperforge.org/plugins/espforum/view.php?group_id=83&forumid=101&topicid=61624
kalyen kumar
Ranch Hand

Joined: Sep 18, 2008
Posts: 53
Hi Martijn Verburg,

It breaks because when I run the report after changing the column name, it will throw an exception that the column name not found.

What I am talking about is a data abstration layer sits between the database and your reports....even if the database structure changes then instead of being required to change what could be hundreds or even thousands of reports throughout an organization, to accomodate the change you instead make the changes in this layer and those changes are automatically passed through to all the reports.

Thanks in advance,
Kalyen
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Yes, you should have a DAO layer of some sort that abstracts this out. Using Hibernate or a similar ORM mapping tool is probably recommended here.
kalyen kumar
Ranch Hand

Joined: Sep 18, 2008
Posts: 53

Hi,

Thanks for your response.
So, if I use hibernate.......and I am directly accessing database without integrating the reporting tool with any application,
then how do I proceed...?

If I use the tool independently (tool interacting directly with database and creating reports) then how can I use hibernate here...?
I am confused.........

Thanks in advance
Kalyen
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Sorry I probably threw you a red herring with my comment. I'd go back to what Gerardo Tasistro said, you'l want to use beans or some other sort of abstraction layer (which could be hibernate or something like that). I suggest you google "Jasper Reports and data Beans" and see what you get..
Gerardo Tasistro
Ranch Hand

Joined: Feb 08, 2005
Posts: 362
kalyen kumar wrote:

If I use the tool independently (tool interacting directly with database and creating reports) then how can I use hibernate here...?
I am confused.........


I've used iReports with Hibernate directly and I don't recommend it. It is a nice solution, but you don't break away completely form the issues you mention. Your report tool still remains coupled to your application because any change to the application's data model. I've moved to using a pure Java Bean solution. It is the responsibility of the application to create an array of such beans and pass it to the report. That way you have:



then you have



Your application should have a way to convert a DataBean to a ReportBean in such a way to create:



Then you fill the report with reportList using JasperFillManager.fillReport(...);
kalyen kumar
Ranch Hand

Joined: Sep 18, 2008
Posts: 53
Hi Gerardo Tasistro,

A very nice response, I am very much happy with your answer.

Thanks a lot.

Is the following same as that you are talking about......?

http://ixfree.wordpress.com/2007/07/04/jasper-ireport/

Thanks in Advance,
Kalyen
Gerardo Tasistro
Ranch Hand

Joined: Feb 08, 2005
Posts: 362
A bit like that. Although I omit the FactoryBean and just pass the data directly

Example from http://www.devdaily.com/java/jwarehouse/spring-framework-2.5.3/src/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsView.java.shtml

kalyen kumar
Ranch Hand

Joined: Sep 18, 2008
Posts: 53
Hi,

Thanks a lot.
I will be starting implementing this with the guidance given by you.

I hope you will be in touch for further guidance, definitely not step by step (because you have already given it )
but if any road blocks I face or for gaining better understanding of things.

Thanks you all,
Kalyen
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ireport generated report breaks