• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How to pass the DTO to the dao implementention layer

 
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anybody please tell me :

How to pass the DTO data of an User Object will be passed to the DAO Layer?
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why in the world would you want to pass DTO data to a DAO layer?
 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me explain

I have a JSP with all the fields and i in the servlet i am creating the DTO instance in the servlet and setting all the entered data in the setters of the User Object , Now i want to pass this data to the DAO Layer to perform a Insert operation .



public void setName(request.getParameter("Name"))
{
}



I am new to development .
Please tell me correct approach if i am wrong
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you describe the DAO layer that you have written? How does it work? What does it consist of?

If you can describe it, then maybe we can figure out to pass data to it.

Maybe something like the following will work for you.

DAO dao = new DAO();

dao.passDataToDAO(userObject);
 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
James , thats what i was asking do we need to pass this DTO Object from the BusinessDelegade Layer to the DAO Implmentation Layer ??
 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please anybody on this ??
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

do we need to pass this DTO Object from the BusinessDelegade Layer to the DAO Implmentation Layer ??



No, you do not "need" to pass this object. Why do you think you "need" to pass this object?
Again, can you describe what this "DAO layer" does? How does it work? Or, how did you design it?
 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This took time to repost

Let me explain

1. front end, I have a user input page

2.which takes the input params and calls DAO to update the data

I had implemented Using Hibernate



MY doubt is how the User Object is being passed to the DAO

where should i call all these ?

User user = new User()

user.setName(request.getParameter("UserName"))

inside the servlet which gets all the data from the JSP page or inside the DAO layer ??
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

inside the servlet which gets all the data from the JSP page or inside the DAO layer ??



It depends. If you are creating a three-tier web application, then you would not have this in the servlet code. The three tiers are Presentation, Business and Integration. The user data is passed down from the Presentation tier to the Business tier. The User object would be created in whatever business logic code exists on the Business tier. The DAO code is part of the Business tier.

If you are not creating a three-tier application, then you basically can create the User object wherever you want to.

 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am talking with respect to the three tier architecture only.

Now in this 3 tier architecture the User Object (The DTO object) will be created inside the DAO layer only?

This is what i understood (with respect to 3 tiers ) .Correct me if i am wrong .

 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Understand that the DAO layer is part of the Business tier.

If you use the User object as both a business object and a DTO, then you will create the User object in the Presentation tier and pass this to the Business tier code. Once the User object is in the Business tier, it is no longer a DTO, it is a business object. If there is any business logic related to processing the User object, then this occurs. To move the data from the Business tier to the Integration tier, you pass the object to the DAO code, and the DAO code stores the record on some data storage device on the Itegration tier.
 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thanks James , i got what you had specified .



Good Explanation.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic