File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Class design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Class design" Watch "Class design" New topic
Author

Class design

Vinod Kumar
Ranch Hand

Joined: Jan 18, 2002
Posts: 75
Hi,

I need to represent a resultset in a tabular form (html table).
I normally use objects (Eg: Product, Employee etc) for simple cases to represent product or employee data from product table or employee table.
I am having a report kind of data where it has to query more than 5 tables and represent two columns from each table in a UI. The DBA provides me a database view, I need to query this. How should my object look like?
The tables are having parent-child relationship, I feel there will be too much work in splitting objects from resultset and then putting them together to represent in UI (JSP). Can I have my class look like what I need in my UI ?? I use DAO pattern with straight JDBC / SQL queries.

Thanks in Advance,
Vinod
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 688

> I need to represent a resultset in a tabular form (html table).

OK, I'm with you so far. I've heard that an HTML table is the right choice to represent tabular data.

> I normally use objects (Eg: Product, Employee etc) for simple cases to represent product or employee data from product table or employee table.

OK. That sounds good to me too.

> I am having a report kind of data where it has to query more than 5 tables and represent two columns from each table in a UI. The DBA provides me a database view, I need to query this. How should my object look like?

Can you do a JOIN in SQL and use an object of the class java.sql.ResultSet to hold the data?

> The tables are having parent-child relationship, I feel there will be too much work in splitting objects from resultset and then putting them together to represent in UI (JSP). Can I have my class look like what I need in my UI ?? I use DAO pattern with straight JDBC / SQL queries.

I don't understand. I looked up DAO on www.wikipedia.org. I am learning. I don't understand why you would need to split up the resultset and put it backtogether in the UI. Isn't the resultset of the JOIN exactly the tabular data that the HTML table is designed to display using a JSP?

Kaydell
[ May 29, 2007: Message edited by: Kaydell Leavitt ]
Dhaval Shah
Ranch Hand

Joined: Jun 10, 2005
Posts: 56
Hi Vinod,
I think you need not split the result set. Just create a class containin the fields that you want in your table (i.e UI) and then render it on the jsp.


Thanks and Regards,<br />Dhaval Shah<br />SCJP 1.4<br />SCWCD 1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class design
 
Similar Threads
Reading XML
Fetching data from parent and child tables
Inner join in Hibernate
Can we use two quries using prepared statement in one method
Is there a way of storing a resultset in a variable (not copying into arrays etc.)