Ayende @ Rahien

Unnatural acts on source code

NHibernate for Reporting...

Just finished writing some fairly complex reports. The reports are complex enough that I decided that it isn't worth my time to try to build a stored procedure to do it, and I simply used NHibernate to get the data. The simplest report had 14(!) parameters, but the main issue was handling security and running business logic as part of the report. (Specifically, a lot of date calculations).

To be clear, I am talking about using NHibernate as a data source for a report, not generating the report itself. That is done with reporting services, which is talking to an NHibernate backed Web Service. Of course, this has the predictable result of:

ayende.DislikedTools.Add( Microsoft.SqlServer.ReportingServices, 
     ReasonsForDislike.DoesNotSupportRightToLeft | ReasonsForDislike.XPathWhoNeedsXPath );

Comments

Rik Hemsley
05/08/2007 09:12 PM by
Rik Hemsley

Ouch... We're considering moving from Crystal Reports, which is just disgusting, and I thought SQL Server Reporting Services sounded interesting - but if it doesn't support RTL...

Did you come up with a workaround?

Ayende Rahien
05/08/2007 09:15 PM by
Ayende Rahien

We got some help from Microsoft, turned out to be a HttpModule that just processed the outgoing HTML and added dir="rtl", but that breaks horribly on aggregation.

Why do you need RTL?

No workaround yet, this is one situation where I can tell the customer, you wanted Microsoft, now you deal with it. Not that I would have another solution, by the way, it is just that I have fun saying that ;-)

Njue
05/09/2007 06:18 AM by
Njue

I've been thinking about using NHibernate on my next project but have been reluctant because of reporting.Its a rich client app and i'm stuck with Crystal Reports which as far as i can tell only takes DataSets as report data source.Any ideas on how i would feed NHibernate query results to such a tool?

Rik Hemsley
05/09/2007 07:08 AM by
Rik Hemsley

We need RTL because one of the languages we produce reports in is Arabic. Oh well, there are other reporting products on the market and I was going to try a few of them anyway...

Ayende Rahien
05/09/2007 10:49 AM by
Ayende Rahien

@ Njue,

It is tirival to transform an object graph to a dataset.

Winston Fassett
05/09/2007 02:56 PM by
Winston Fassett

Ayende, could you summarize the trivial operations involved? I, too, would like to know how you transformed your object graph to a dataset and wired it up to MSRS.

Ayende Rahien
05/09/2007 03:35 PM by
Ayende Rahien

Winston,

see next post about it.

Scott Willeke
05/09/2007 04:42 PM by
Scott Willeke

Can you email me some more information about both how you used (or would prefer to use) NHibernate with reporting and also specifically what problems you have with RTL in RS. We've just released a public beta of Data Dynamics Reports which, among other things will read RDL files, and does support RTL (although I thought RS did too). I'm interested to know what features we might be able to add to help make using NHibernate, RTL more useful in reporting. I'd add XPath to that list, but I think it's hopeless :)

Scott Willeke

Data Dynamics

http://www.datadynamics.com/

Jericho
05/11/2007 02:51 PM by
Jericho

Hi Ayende!

Im using HN in my project and I think NHibernate isnt appropriate for complex reporting or may be my knowledges are not enough for this stuff.

Could you recommended me any information for using NH for reporting and any tips& tricks would be very useful!!!

Thanks!!

Ayende Rahien
05/11/2007 03:25 PM by
Ayende Rahien

Normally,I wouldn't use NHibernate for reports, SQL is usually better at this sort of thing.

The scenario that I was facing is a legacy database schema that I have already mapped to NHibernate and reports that contained business logic.

Therefor, I choose to do reporting via the business layer.

Normally, I would suggest reports to use SQL directly.

Ayende Rahien
05/11/2007 03:26 PM by
Ayende Rahien

That said, Hibernate in Action has a section on reporting queries, and I thinks the docs as well.

Kevin
06/05/2007 05:58 PM by
Kevin

Hi Ayende,

I am currently struggling with how to handle retrieving data in large sets (~10,000 records) while still working within the DDD approach I have started. I have been studying your approach using repositories and I am working on implementing a set of specific repositories for things in my system. One is a StudentRepository which is responsible for managing the students in our system. Most of the repository methods are like Save, Remove, Get, Find, etc. These all use NHibernate to do their work. How would you go about implementing a requirement of "Retrieve students matching some criteria and save results to a downloadable Excel file" where the results could be upwards of ten thousand records? Would this be the responsibility of the repository or some other service? I am just looking for some advice or suggestions.

Thanks!

Comments have been closed on this topic.