Questions tagged [dao]

In computer software, a data access object (DAO) is an object that provides an abstract interface to some type of database or other persistence mechanism. From Wikipedia: http://en.wikipedia.org/wiki/Data_access_object

In computer software, a data access object (DAO) is an object that provides an abstract interface to some type of database or other persistence mechanism. By mapping application calls to the persistence layer, DAOs provide some specific data operations without exposing details of the database. This isolation supports the Single responsibility principle. It separates what data accesses the application needs, in terms of domain-specific objects and data types (the public interface of the DAO), from how these needs can be satisfied with a specific DBMS, database schema, etc. (the implementation of the DAO).

From Wikipedia: Data Access Object

55 questions
31
votes
3 answers

Should service layer catch all dao exceptions and wrap them as service exceptions?

I have three layer Spring web app: dao, service and controllers. A controller never calls directly the dao, it does it through the service layer. Right now, most of the time if there is dao exception (runtime) that is not handled, it'll be caught…
Oscar
  • 453
  • 1
  • 4
  • 7
19
votes
3 answers

In MVC , DAO should be called from Controller or Model

I have seen various arguments against the DAO being called from the Controller class directly and also the DAO from the Model class.Infact I personally feel that if we are following the MVC pattern , the controller should not coupled with the DAO ,…
user65878
16
votes
3 answers

Should a DAO be singleton or not?

I am developing a RESTful API and I think it is convenient to use DAOs for my resources because although I plan on just using memory to store them, I don't want to close a door to whoever is using my library if they decided to use a database…
dabadaba
  • 2,216
  • 6
  • 25
  • 35
12
votes
3 answers

How to manage 2 DAO methods in a single transaction?

In an interview someone asked me : How do we manage 2 transactional/dao methods in a single transaction. Desired capabilities: If anyone of them fails we need to rollback both methods. Both of the methods can be called separately attached with a…
Satish Pandey
  • 1,340
  • 3
  • 10
  • 20
11
votes
2 answers

Repository pattern vs DAO managing Entities

I am new to concepts like DAO, DAL and Domain Driven Design. In the end I want to decouple the persistence layer (mysql database) from my business objects and logic in a web application. I liked the DAO concept but I got stuck implementing it when I…
Michbeckable
  • 221
  • 1
  • 2
  • 4
7
votes
4 answers

Are there any real benefits to a DAO layer?

When I first started using Hibernate I heard about all the joy of using a DAO layer. Initially it made sense for my problem: I was going to experiment with Hibernate and later experiment with NoSQL and/or XML for experience. It made sense at the…
TheLQ
  • 13,478
  • 7
  • 55
  • 87
7
votes
3 answers

Transaction handling in DAO or Service layer in pure JDBC without frameworks

I have an application which works with pure JDBC. I have a dilemma where should transaction handling go, in Service or DAO layer. I have found that in most cases it should be implemented in Service layer since DAO must be as simple as possible and…
rand0rn
  • 189
  • 1
  • 1
  • 7
7
votes
1 answer

How much of the data preparation, transformation, and processing belongs in Repository layer?

I have a use case where I display variables in a PDF file. But to get there is not simple, but I could do something like this: /* * takes product model number, retrieves, processes, formats values * returns $variables, ready to plug-in to view…
Dennis
  • 8,157
  • 5
  • 36
  • 68
7
votes
2 answers

What is a good reason for separating intelligence and dao layers in a microservice?

I am having a long-term debate with my architect about architecture choices. The entreprise where I work in is migrating from a monolithic architecture to a microservices one. The debate is located on the good approach for handling database access.…
6
votes
2 answers

Using a DAO to abstract our ORM from the rest of the application

We're using MySQL with Sequelize.js as the ORM. What we're wondering is whether a DOA layer of abstraction is worthwhile. Here are our options: To use the Sequelize models throughout the application. To abstract Sequelize by building a layer that…
Matt
  • 293
  • 3
  • 10
6
votes
3 answers

SQL RDBMS : one query or multiple calls

After looking around the internet, I decided to create DAOs that returned objects (POJOs) to the calling business logic function/method. For example: a Customer object with a Address reference would be split in the RDBMS into two tables; Customer…
None None
  • 69
  • 1
  • 2
5
votes
2 answers

OOP Objects, nested objects, and DAO's

Here's something I keep struggling to figure out the best solution to. I've had this problem while working with PHP and Java so it's a fundamental understanding of OOP issue. Examples are in PHP. Let's say I have a few object's here. Song, Artist,…
user103555
  • 51
  • 1
  • 2
4
votes
2 answers

What's the correct approach to DAO layer in presence of ORM framework

I'm using JPA/Hibernate but probably it doesn't limit question. Currently I'm writing my data access code in my web controller classes. Thanks to JPA, in most cases this code is very simple, basically simple query with trivial setup. I tried to move…
vbezhenar
  • 141
  • 4
4
votes
2 answers

Pattern for caching DAOs: strategy or decorator?

I'm building a php system with the Services/DAOs/Domain Models pattern, and now is the time to implement a caching system for the DAOs. Would you use a decorator pattern, or maybe the strategy pattern? What are the ups and downs of each one? added…
AntonioHS
  • 187
  • 1
  • 9
4
votes
1 answer

DAO/Webservice Consumption in Web Application

I am currently working on converting a "legacy" web-based (Coldfusion) application from single data source (MSSQL database) to multi-tier OOP. In my current system there is a read/write database with all the usual stuff and additional "read-only"…
1
2 3 4