The moose likes Object Relational Mapping and the fly likes how to access DAO Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "how to access DAO" Watch "how to access DAO" New topic
Author

how to access DAO

Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 366
Hi! This is a design question.

I'm using Hibernate and DTO for annotation mapping. I have DAO objects for persistance of these objects. My question is. How should I access the DAO objects.

Should I instantiate the DAO or is there some pattern on how to wrap the DAO?


SCJP1.4
dennis zined
Ranch Hand

Joined: Mar 07, 2003
Posts: 330
You'll probably have a service layer in your application which you could inject dao components via Spring framework. In your spring config, inject DAOs into your service component and expose service methods to your UI. Your code will probably look like this:



hope this helps.


SCJP 1.4<br />SCWCD 1.4
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 366
Thank you!

Not to familiar with spring but i'll look into it. To many new framworks for me right now , Wicket, Hibernate, Maven, Struts2 and the list goes on. But I have read about the Service Layer and seems like a good id�.

// Mathias
 
 
subject: how to access DAO
 
Threads others viewed
Hibernate & J2EE
dao pattern
Is Business Object really necessary?
Hibernate & J2EE
How to write a simple generic DAO class?
developer file tools