File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes MVC  architecture. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic

MVC architecture.

Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
is it a right practice to use the same bean for doing database manipulation and storage ??? i mean, does it affect performace if i use a bean for database access and the same bean for setters and getters ?? or shld i used one bean for database related things and another bean for getters and setters ??? i think making confusion !! ..
not sure if this is the right forum to post this message..if therez any other forum for MVC architecture , plz gimme the url..

SCJP, SCWCD, SCBCD, Oracle Certified Professional (SQL n PL/SQL)
Andy Bowes
Ranch Hand

Joined: Jan 14, 2003
Posts: 171
Please don't post to more than one forum. Cross-posting just makes following the threads of discussion so much harder.
The problem that you are talking about is not really MVC architecture at all and is really about database access design patterns.
The patterns that you are applying are well-known and well-defined. In my opinion you should create 2 separate classes:-
The first class would be a Value Object which is basically just a plain old Java bean with the getters & setters.
The second class is a Data Access Object which instantiates the Value Objects by appling SQL SELECT statements against the database and handles the UPDATE, INSERT and DELETE statements.
Hope this helps

Andy Bowes<br />SCJP, SCWCD<br />I like deadlines, I love the whoosing noise they make as they go flying past - Douglas Adams
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
hi andy,
thanks for ur expert really sorry for posting my message in jsp and servlets forum..i didnt know where to post my message so just thought to put it in both forums...anyway i wont repeat it..
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Continue the conversation here.

"JavaRanch, where the deer and the Certified play" - David O'Meara
It is sorta covered in the JavaRanch Style Guide.
subject: MVC architecture.
jQuery in Action, 3rd edition