Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Building a report engine where sql queries are inside a database table

forumKid2Jun 2 2010 — edited Jun 2 2010
I've been asked to build a reporting engine. Management wants it extensible enough to be able to change database values and for the reports to change. This all needs to be done without having anyone have to make any Java changes.

I know it can be very cumbersome having queries inside database tables because it adds in the constraint of the database, but thats the requirement right now.

First I'm looking to see if anyone has implemented something like this and what issues they came into, so I can obviously stay away and learn from that.

My second question is how to dynamically do the data transformation. I normally create a separate class that maps to the database table fields. Then I load that object into a Set or List.

Since the sql is inside the database, Ill never know exactly how many fields are being selected or what tables are being selected from. Today the query could return 3 fields. Tomorrow it could be 4 fields. Because of that, I cannot create a class that maps to the database fields because I do not know how many fields will be returned from the query. I guess I could create a generic class (set and get) that has lets say 20 fields or whatever the maximum # will be, and use that. I dont really like that idea, hence for my post.

Here is an example class that I was talking about above. Where it relates to my database fields and then I load this into a Set or List, etc. This is normally how I do it when I know what table/fields are to be returned. But since the sql will be in the database and it will be one generic program that needs to handle multiple queries, Im unsure of the best approach here.
public class Employee {
	 	 
	     String firstName;
	     String lastName;
	     String gender;
	 
	    public Invitee(String fn, String ln, String gen){ 
	        firstName = fn;
	        lastName = ln;
	        gender = gen;
	    }
	}
For example I could have these two queries inside the database in two separate fields
select firstname, lastname, gender from employee;
select color, type, width, height, weight from inventory;

The best way to load them into a Set or List using one modular program. It's really the design that I'm looking for help on.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 30 2010
Added on Jun 2 2010
3 comments
289 views