• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

ireport generated report breaks

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How/why does it break?
 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
You're not going crazy. You're going sane in a crazy word. Find comfort in this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic