Hi Joel,
your English is fine. Best practices would normally dictate that you fetch everything you need from the database in one hit.
It does depend on what framework or coding pattern you are using for your database access though. I assume you are coding simple JDBC API calls?
I would strongly recommend a quick and easy lightweight object / relational mapping framework like iBatis.
But generally I would obtain the Message DTOs in the data services layer and
populate them with the user information from a resultset obtained joining both
tables. A quick and dirty technique would be to put the UserName attribute
directly on the Message bean.
But be careful of anti-patterns!
Regards
Adam
Joel Alejandro Espinosa Carra on 20/05/06 00:19, wrote:
Hi all.
I think this is kind of a basic question. I have an application that
haves 3 tables: users, messages and user_inbox for the relationship of
first 2 ones. I have a class named MessagesManager in order to manage
the messages to-and-from the database throught the business methods, one
of them is the public List getMessages(String user_id) method that
returns a MessageBean's list and I need to display the messages of each
user in a html table, the MessageBean only contains the user_id but I
want to display their names, do I need to modify my business method in
order to get the usernames? or do I need to add another method to get
the usernames, something like public String getName(String user_id)?,
the first aproach makes one query to the database and the second aproach
makes two. What is the best practice here?
As you can see english is not my navite language, I hope you guys can
understand my issue.
Thanks in advance.
Have a nice weekend.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]