I'm working on a J2EE application and using stateless EJB's to access an oracle DB. I have a series of reports that I have to present in JSP's. I have about 15 different select statements and stored procedures that I have to execute. I want to make this as flexible (since contents of the report sometimes change)as possible and I don´t think that having a method for each select is a good idea.
I thought about having an interface where I would declare strings with each select statement but it doesn't "feel" clean.
Can someone give me some hint on a good design for this reports?
I would try to find the logical relationship between the data you need in the report and construct some bean (value holder) classes to represent it. The purpose of this is to create a new model that will help you get some reuse out of your objects especially once they are already created from the db.
I would create a Customer object that contains a List of purchase objects. The fields in these classes should be the
same type as the EntityBean or database type that you are using to pull objects from.
Then create a session bean that pulls the objects from the database and creates a Collection to hold your new value holder classes. Iterate through your db objects and create new Customer and Purchase objects, add each one to your collection.
Once you have your new model (the collection of beans) return it to some outside handler for specific grouping and
sorting for each report.
The re-use will come when your model can be changed for each report type you need.
I've undergone a similar execise some time ago.
- if the reports are complex and your budget is sufficient budget try to use a COTS package. I can't recommend any particular one but there are some reasonably mature products out there.
- if you can't use a package then it will be a bit messy as lots of time will be spent on formatting and layout.