aspose file tools*
The moose likes JDBC and the fly likes Problem in Bean 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 » Databases » JDBC
Reply locked New topic
Author

Problem in Bean Design

mohsin sheikh
Greenhorn

Joined: Mar 28, 2007
Posts: 22
I am developing a project as Task Tracking System.One of the entities used in my project are Client and Task.So i build the bean for Client and Task.
The Client Bean consists:Client Id,ClientName,ClientStatus.The Task bean consists of TaskId,TaskName,Description,CreateDate,TaskStatus etc.The Relation between client and task is of one to many relation.So I include Clientid in Task Bean.Now i want to show the list of task with their client as

ClientName ClientStatus TaskName CreateDate TaskStatus....

For this i am getting the above data from the database .Now i want to set the bean properties after getting the resultset from the database.Now the problem is that which bean property should i set.If i set the Task property,i will do as follows....
Task task=new task();
task.setTaskName(rs.getString(1))
task.setClentId(rs.setClientId(rs.getInt(2))....etc

Now how will i set the property for ClientName and Client Status properties.
And i want the total records in a bean so that i can print the bean value using get method on JSP.So how should i set the bean value and store that in ArrayList so that i can print all the information.Please resolve the above problem and also new ideas to solve the above problem in another way is most welcome.If you can provide some code then it will be very useful to me.But any way i will stick to setting bean properties.
Thanks in advance
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29233
    
136

Mohsin,
It looks like there is a logical relationship between the two. Maybe that a task is owned by a client? You could have a client field on the task object.

Or if this is only used for data transfer, you could have a new object with all the fields you need. A bean without logic (and just data) doesn't need to represent a domain object. It is literally representing a row.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Manuel Leiria
Ranch Hand

Joined: Jul 13, 2007
Posts: 171
Double post

java intermediate


Manuel Leiria<br /> <br />--------------<br />Peace cannot be kept by force; it can only be achieved by understanding. <br /> Albert Einstein
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29233
    
136

Manuel,
Thanks for pointing that out. I'll close this copy so all discussion can continue in one place.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in Bean Design
 
Similar Threads
Problem in Bean(Design)
Problem in setting bean value
Problem in setting form bean
Problem in Bean Design
Problem in Bean(Design)