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

Large Reports made of Complex Data. Suggestions?


victorg

Recommended Posts

 Hello.

 

1. I have some LARGE reports based on a direct DB query that could return a potentially huge number of rows. They work very well, the virtualizer does its job, and all is nice and happy.

 

2. On the other side I have other Reports made of ONE unique ´row´ which could be a very complex item, that is, just a 1 or 2 pages long report made of a complex variety of related entities. Typically, this report can be made of 15 to 20 subreports distributed in 2 to 4 levels.

 

For the scenario 2.,  (when the report is never potentially large in number of main elements) I never give Jasper direct access to DB data, because the DB data is raw data and needs to be processed by business and presentation logic before. I prefer to pass Jasper the data ready to be reported, formatted, etc. so Jasper just ´prints´ and don´t deal with data transformation nor processes anything.

(You don´t generally allow your UI components to access directly the DB layer, right ?)

So the way I do that is by using an XML doc. data source. I get the data with my Java Beans or classes, they deal with the processing and presentation logic and return to me an XML document with just the necessary information ready to be printed. 

That is my absolute preferred approach and this is what I always do UNLESS I´m unable to do so for any reason (like case 1.).

 

 

The PROBLEM now is that I need both things. I have DB Query that returns a potentially huge list of elements of type 2 to be reported, and I would like to know what would be the best suggested method to accomplish that.

I would like to execute a DB query, benefit from the virtualizer to manage the huge returned list of elements, but at the same time I need to process each data row as case 2. before passing it to a Jasper Report template.

Is not as easy as printing a Report row per DB query row. There is a complex report per retrieved DB row.

I can not use the XML data source for the entire report because it could eventually be too big for that.

 

I was thinking on a main Report based on a DB Query and for each returned element, call a utility method in my Java classes that would return a XML document that would be passed to a subreport.

Is that possible?

Is there a better solution I´m missing? what would be the preferred approach taking into account the many datasources and combinations Jasper supports?

 

Thank you very much

Victor



Post Edited by victorg at 07/29/2010 14:56



Post Edited by victorg at 07/29/2010 15:01
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

maybe you could pass your data to thereport as a LazyList (a list that gets its data on demand).

There's an example here:

http://www.ilikespam.com/blog/paging-large-data-sets-with-a-lazylist)

You will just have to remember clearing the loaded data in order to avoid memory usage problems.

Doing this way, you would implement at least two methods: one for retrieving how many results there is in the list; and another for querying the data to be presented, page by page. You can do some tests to figure out the right page size.

hope it helps, cheers

Link to comment
Share on other sites

  • 2 months later...

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...