Peter Jin | 3 Jun 2009 10:45
Picon

How about loop a sub report?


Hi,
I may need to put several sub reports in the detail section in the master
report. So the sub reports will get loaded many times. Will this cause
significant performance issues? Does jasper cache data source for report in
this case?

My case:
User's data are scattered in 5 tables and I need to put those data together
under a particular user. I don't want to use UNION because HQL doesn't
support it. In addition, Union 5 tables may result in a huge SQL. I have to
use one sub report for each table and iterate users in master report and for
each user iterate all sub reports to display data relevant to that user.

Is this viable or any other solution?

Any comment is appreciated.
--

-- 
View this message in context: http://www.nabble.com/How-about-loop-a-sub-report--tp23847733p23847733.html
Sent from the jasperreports-questions mailing list archive at Nabble.com.

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
chr15athome | 3 Jun 2009 11:15
Picon

Re: How about loop a sub report?


Hi Peter,

If I understand your requirements correctly I think grouping would be better
than having multiple subreports.

Grouping the data on users allows you to create a seperate table for each
user, you can also have a header and footer for each user and you can also
perform calculations and have totals at the bottom of each group.

Hope this helps.

Chris

Peter Jin wrote:
> 
> Hi,
> I may need to put several sub reports in the detail section in the master
> report. So the sub reports will get loaded many times. Will this cause
> significant performance issues? Does jasper cache data source for report
> in this case?
> 
> My case:
> User's data are scattered in 5 tables and I need to put those data
> together under a particular user. I don't want to use UNION because HQL
> doesn't support it. In addition, Union 5 tables may result in a huge SQL.
> I have to use one sub report for each table and iterate users in master
> report and for each user iterate all sub reports to display data relevant
> to that user.
> 
(Continue reading)

chr15athome | 3 Jun 2009 11:18
Picon

Re: How about loop a sub report?


Sorry I forgot to mention that the info I gave is based on using
iReport/jasperReports, not sure what you are using now but I definately
recommend iReport.

Chris

chr15athome wrote:
> 
> Hi Peter,
> 
> If I understand your requirements correctly I think grouping would be
> better than having multiple subreports.
> 
> Grouping the data on users allows you to create a seperate table for each
> user, you can also have a header and footer for each user and you can also
> perform calculations and have totals at the bottom of each group.
> 
> Hope this helps.
> 
> Chris
> 
> 
> Peter Jin wrote:
>> 
>> Hi,
>> I may need to put several sub reports in the detail section in the master
>> report. So the sub reports will get loaded many times. Will this cause
>> significant performance issues? Does jasper cache data source for report
>> in this case?
(Continue reading)

Peter Jin | 3 Jun 2009 11:22
Picon

Re: How about loop a sub report?


Hi Chris,

Thanks for your reply.
Grouping can not solve my issue because it works on one data source only. In
my case, data for a user scattered in 5 tables. UNION might be a way to
combine all tables to a data source, but I can not use it either (explained
in the first post). any thoughts?
--

-- 
View this message in context: http://www.nabble.com/How-about-loop-a-sub-report--tp23847733p23848221.html
Sent from the jasperreports-questions mailing list archive at Nabble.com.

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
chr15athome | 3 Jun 2009 13:28
Picon

Re: How about loop a sub report?


Its hard to give advice when I have no real idea of your data structure, I am
unsure why you would have seperate tables for differents users unless you
mean graphically.

If you have 5 separate tables 1 for each user then UNION seems to be the
only way to do it, unless you know Java, you could put the data into beans
and use a bean datasource to build your report.

I always find that subreports can normally be replaced with groups, I
personally hate subreports...lol.

Chris

chr15athome wrote:
> 
> Sorry I forgot to mention that the info I gave is based on using
> iReport/jasperReports, not sure what you are using now but I definately
> recommend iReport.
> 
> Chris
> 
> 
> chr15athome wrote:
>> 
>> Hi Peter,
>> 
>> If I understand your requirements correctly I think grouping would be
>> better than having multiple subreports.
>> 
(Continue reading)

David Bolen | 3 Jun 2009 20:11
Picon

Re: How about loop a sub report?

Peter Jin <jinyuping@...> writes:

> Grouping can not solve my issue because it works on one data source only. In
> my case, data for a user scattered in 5 tables. UNION might be a way to
> combine all tables to a data source, but I can not use it either (explained
> in the first post). any thoughts?

It's still somewhat unclear without knowing more about your table
structure, but if you just mean that you have a reasonably normalized
schema where the relevant information is stored in several tables with
appropriate foreign key relationships (this can be true even if normal
access is controlled by an ORM like Hibernate), is there a reason your
report query can't just join the relevant tables together, grouping
the result by user?

If you mean 5 completely distinct data sources (e.g., separate
databases), then another thought (if you have control of the code
rendering the report) might be to implement a custom data source that
itself performs the integration from the multiple data sources, even
if via 5 distinct queries.  From the Jasper engine's perspective it
would still be utilized as a single data source for the report.

-- David

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
(Continue reading)

Peter Jin | 4 Jun 2009 09:40
Picon

Re: How about loop a sub report?


We have an audit system which uses separate tables with similar structure to
store different kinds of activities for a user. We want to report the number
of activities per activity type per user.

David Bolen-2 wrote:
> 
> Peter Jin <jinyuping@...> writes:
> 
>> Grouping can not solve my issue because it works on one data source only.
>> In
>> my case, data for a user scattered in 5 tables. UNION might be a way to
>> combine all tables to a data source, but I can not use it either
>> (explained
>> in the first post). any thoughts?
> 
> It's still somewhat unclear without knowing more about your table
> structure, but if you just mean that you have a reasonably normalized
> schema where the relevant information is stored in several tables with
> appropriate foreign key relationships (this can be true even if normal
> access is controlled by an ORM like Hibernate), is there a reason your
> report query can't just join the relevant tables together, grouping
> the result by user?
> 
> If you mean 5 completely distinct data sources (e.g., separate
> databases), then another thought (if you have control of the code
> rendering the report) might be to implement a custom data source that
> itself performs the integration from the multiple data sources, even
> if via 5 distinct queries.  From the Jasper engine's perspective it
> would still be utilized as a single data source for the report.
(Continue reading)

Peter Jin | 4 Jun 2009 10:26
Picon

Re: How about loop a sub report?


Thanks a lot for your comments. We have an audit system which uses separate
tables with similar structure to store different kinds of activities for a
user. We want to report the number of activities per activity type per user.
I'll consider to create a view first.

chr15athome wrote:
> 
> Its hard to give advice when I have no real idea of your data structure, I
> am unsure why you would have seperate tables for differents users unless
> you mean graphically.
> 
> If you have 5 separate tables 1 for each user then UNION seems to be the
> only way to do it, unless you know Java, you could put the data into beans
> and use a bean datasource to build your report.
> 
> I always find that subreports can normally be replaced with groups, I
> personally hate subreports...lol.
> 
> Chris
> 
> 
> chr15athome wrote:
>> 
>> Sorry I forgot to mention that the info I gave is based on using
>> iReport/jasperReports, not sure what you are using now but I definately
>> recommend iReport.
>> 
>> Chris
>> 
(Continue reading)

chr15athome | 4 Jun 2009 10:54
Picon

Re: How about loop a sub report?


Yes I overlooked using JOIN. Used to use JOIN for multiple tables in my old
system.
If you are not up on Joins I have an example I can send.

David Bolen-2 wrote:
> 
> Peter Jin <jinyuping@...> writes:
> 
>> Grouping can not solve my issue because it works on one data source only.
>> In
>> my case, data for a user scattered in 5 tables. UNION might be a way to
>> combine all tables to a data source, but I can not use it either
>> (explained
>> in the first post). any thoughts?
> 
> It's still somewhat unclear without knowing more about your table
> structure, but if you just mean that you have a reasonably normalized
> schema where the relevant information is stored in several tables with
> appropriate foreign key relationships (this can be true even if normal
> access is controlled by an ORM like Hibernate), is there a reason your
> report query can't just join the relevant tables together, grouping
> the result by user?
> 
> If you mean 5 completely distinct data sources (e.g., separate
> databases), then another thought (if you have control of the code
> rendering the report) might be to implement a custom data source that
> itself performs the integration from the multiple data sources, even
> if via 5 distinct queries.  From the Jasper engine's perspective it
> would still be utilized as a single data source for the report.
(Continue reading)

David Bolen | 5 Jun 2009 02:17
Picon

Re: How about loop a sub report?

Peter Jin <jinyuping@...> writes:

> We have an audit system which uses separate tables with similar structure to
> store different kinds of activities for a user. We want to report the number
> of activities per activity type per user.

Still sounds pretty standard in terms of database schema.  Can I
assume that these separate activity tables have some field or unique
key that correlates back to a user table or table containing per-user
information?  If so, then unless the tables are stored in separate
database servers, it sounds like you just want to join those tables as
part of the primary query without much hassle.

Dumb example - you have a set of users, who can get rows added to one of
three activity tables, related to three activities that have different
metrics.  Each row in an activity table is a single instance of that
user performing that activity:

   users
      id integer primary key
      name text

   activity1
      user_id integer -- foreign key references users(id)
      distance integer

   activity2
      user_id integer -- foreign key references users(id)
      hits integer

(Continue reading)


Gmane