• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DAO for web application

 
Andrew Kessel
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
I would like to create the web application that can work with ORM entities. Servlets, that, through DAO class, can CRUD entities. DAO formalize as Spring-bean and for each operation with entities, servlets must create an object of DAO class through Spring.
Is that right? What problems may result?
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There should be a business object in between the servlet object and the DAO. And there typically should be a delegate object between the servlet and business object.

Servlet object -----> Business Delegate -----> Businesss Object ------> DAO object -------> Database

------------(Presentation tier)------------------------------(Business tier)---------------- (Integration tier)
 
Andrew Kessel
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like JSP, that invoke servlet?
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please write a complete sentence.
 
Andrew Kessel
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There should be a business object in between the servlet object and the DAO. And there typically should be a delegate object between the servlet and business object.

Business object should contain CRUD methods that invokes DAO's CRUD methods? What methods must contain Business Delegate?
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keep in mind that so far we are only speaking in abtract terms. In order to completely go into details we would need the requirements for the application, including details about logic, operations, features and functions.

Business object should contain CRUD methods that invokes DAO's CRUD methods?


No. The Business object should contian methods that implement whatever logic the application is written to have. Inside the implementation of these methods, the methods of one or more DAO objects are called.


What methods must contain Business Delegate?


A Presentation-tier Business Delegate should have methods that enable the execution of a business object's methods.

Ideally, you should be able to execute business methods from a command line (for testing outside of a web container for example).
 
Arun Giridharan
Ranch Hand
Posts: 290
Debian Fedora Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the purpose of Delegate ??
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eliminate any dependency on a Presentation method from the business object model. A single business object model should be executable from multiple Presentation technologies.
 
Andrew Kessel
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok.
I have that structure of web-app: Servlet > Service Object > DAO > Database. Service object, DAO, Session Factory and DBCP connection pool - are Spring beans.
When user send request to servlet, Spring container create copy of Service Object bean, copy of DAO bean, copy of Session Factory bean and copy of DBCP pool? How I may be sure of that all request use one copy of Session Factory bean and DBCP pool&

beans.xml


Service Object - BookService.java


DAO - BookHome.java


Servlet - ViewAllBooks.java

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic