users@glassfish.java.net

JavaEE5 - Generate CSV-File in EJB?

From: Sebastian Hofmann <sebastian.hofmann_at_sourcepark.de>
Date: Wed, 03 Mar 2010 18:03:38 +0100

Hi,

I have to create a CSV file from database records by also invoking some
other business methods. The file might become very large...

Please don't ask why - the customer just wants to have it that way...

Following the architectural approach of JavaEE, I should generate a list
of value objects in EJB, return it to my JSF controller and write it to
the output stream... But in case of many rows/value objects this would
heavily increase the memory consumption of the server...

I also could make the call to the database in the JSF controller,
iterate over the result set and write the rows to the output stream. The
disadvantage here is that I "bypass the architecture" (I think so...)
especially since I usually have to invoke some business methods of EJBs...

I also found the "streaming presidents example"[1]. But this is also not
a satisfying solution...

Is there any other way? Bypassing the output stream from the controller
to the EJB is not possible, I think...!?

Thanks for advice...

Regards
Sebastian


[1] http://www.ahmadsoft.org/articles/stream/presidents.html