Jump to content
Changes to the Jaspersoft community edition download ×

Reusing a datasorce in mutiple subreports


tdiffenbach
Go to solution Solved by lucianc,

Recommended Posts

I wish to reuse, in its entirety, a datasource in multiple subreports. The SQL is relatively expensive, so I'd like to avoid generating it multiple times.

 

It appears that this will require

 

a. Using a JRRewindableDataSource in the main report, and

b. calling moveFirst() on that datasource in each subreport.

 

How can I do this? I don't see a way to specify the type of the main report's datasource type, and I'm not clear how to ensure the call moveFirst() on the datasource in the subreport happens prior to the subreport accessing the datasource's data.

 

Thanks.

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Solution

a. Reports that embed SQL queries use JRResultSetDataSource as data source, and this type is not (currenlty) rewindable. If you think rewindable SQL data sources would be useful, please post a feature request for this.

 

You can also achieve this outside JR by writing a custom SQL query executer that uses TYPE_SCROLL_INSENSITIVE statements to create rewindable result set data sources.

 

If the result set is small, an alternative to this is to execute the result set before starting to fill the report, record all the data returned by the result set in an in-memory structure and then use the in-memory data as data source for the subreports.

 

b. You could, for instance, use the auto rewindable data source wrapper posted here.

 

HTH,

Lucian

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