File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Design patterns for JSP/JavaBean/Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Design patterns for JSP/JavaBean/Database" Watch "Design patterns for JSP/JavaBean/Database" New topic
Author

Design patterns for JSP/JavaBean/Database

Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi,
While designing a 3-tiered application, what is the Best Design Pattern to manage transferring the data between the Database and the Bean layer?
To be more specific, should the JavaBean layer get it's data just once from the Database, and then hold that data at the JavaBean level until the JSP requests additional DB interaction.When should we consider synchronization of data, so that there is miminal performance hit
Thanks in advance.
Regards,
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56

  5. [This message has been edited by Desai Sandeep (edited April 26, 2001).]


<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Desai Sandeep:
While designing a 3-tiered application, what is the [b]Best Design Pattern to manage transferring the data between the Database and the Bean layer?[/B]

There is no single answer. You will want to cache data in a session-bound bean only if the data is session specific, will not be mutated elsewhere (or can be treated as such), and if its size is small compared to the time it would take to retrieve it.
- Peter
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi,
Is it a good practice to defer the synchornization, until there is a request for the some data from the Database, or should it be on insertion of a new record.
What is the general trend.Is there already any available pattern for this?
Thanks in advance,


------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
It's becoming boring, but again no single answer.
If you are sure you're usually going to need all the data, or there is no appreciable extra overhead in loading up all the data, then you don't bother with lazy loading: the extra tests (if (data == null) then load) are just an extra bit of complexity and wasted CPU cycles.
If, on the other hand, the data is bulky and/or it takes extra time to load, and you are not sure that the data will be used, by all means defer loading.
- Peter
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi Peter,
I am with you!!
It must depend on the kind of application you have.Perhaps, this could be the reason, Oracle Business Component for Java(Oracle implementaion on the lines of EJB!!...IMHO, it is better than EJB!!) provides all the options to the developer - lazy loading,synchorinization at the time of update, insert, etc.
Regards,

------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Design patterns for JSP/JavaBean/Database