Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

2
votes
1answer
44 views

Custom messages to UI from DAL?

I have an Asp.net MVC application and sometimes I want to give a descriptive error message to the user, but the condition of it is discovered at the Data Access Layer (DAL). So for example, I have a ...
0
votes
1answer
59 views

Cross-cutting concerns in package-by-feature structure

What is your suggestion on where to put cross-cutting concerns in a package-by-feature structured app? This aspect seem to be missing from most of the pro package-by-feature articles I have read. ...
-1
votes
1answer
51 views

Consuming Rest, DAO or Service layer?

I feel like this is a dumb question but here it goes: If i'm consuming rest (getting data and transforming in POJO), does it sit in the DAO or Service layer? As for what i've researched I believe that ...
0
votes
0answers
111 views

Can we use DAO(Data Access Object) instead repository in onion Architecture?

we are design a project in Onion Architecture. I read in various articles about the differences between dao(Data Access O and repository. In fact, we saw the structure of my project required to use ...
1
vote
2answers
190 views

How should the service layer be done?

so I have this android app at work, if I understand it right the DAO/services/UI layers is to "decouple" the UI from the database. I have 2 problems with that : 1/ Decoupling Like this if things ...
1
vote
4answers
203 views

Little value in unit-testing the database component

Having a component that represents the database is wonderful! You can use it from the business logic to read and write data. But should that component be unit-tested? I would argue that it should ...
0
votes
1answer
223 views

MVP - Model Layer Architecture - Where and how to Setup Entities and DAO

I'm coding a "small" application using MVP pattern that gets it's data from a SQL database. I'm not using an ORM out of the box, and for the sake of learning, I'm writing my own simple ORM/DAO type ...
1
vote
1answer
58 views

Should the Service interface not extend the DAO?

I'm writing the service layer for my DAO and I've made it extend the DAO interface. It looks a bit like this: public interface FooDAO { Foo get(long id); boolean update(Foo foo); These two ...
0
votes
0answers
572 views

DAO vs Repository when extending spring data jpa repositories

I read several articles about diff between DAO and Repository patterns. From what I understood repository should not have query smth like this List query(AccountSpecification specification); and ...
0
votes
2answers
109 views

Should I create a Repository Container to get my repositories?

@Component public class RepositoryContainer { @Autowired public CommentRepository commentRepository; @Autowired public ItemRepository itemRepository; @Autowired public ...
2
votes
2answers
4k views

Using Map to pass query parameters in DAO

It's very common see a generic's DAO implementation like this: public List<E> getResultList(String namedQuery, Map<String, Object> parameters) { Query query = entityManager....
2
votes
0answers
76 views

Idea on replacing DAO/Domain obj pattern

I know someone has probably already thought of this, but here is a way to replace DAOs and Domain objects: For example public class Bike { private int id; public Bike(String model) { //...
0
votes
1answer
812 views

If Service Layer is doing nothing, just calling methods in DAO . Can my Service Interface just extend DAO Interfaces?

Why do we need to write same methods in Service Interface, when we just want a replica of DAO Interface. interface DAOI { method1(); method2(); } interface ServiceI extends DAOI { } instead of ...
3
votes
1answer
197 views

What is the generic implementation of design pattern IoC coupled with Factory for DAO? [closed]

I'm learning the java Spring framework. So far, I understood that Spring will make stuff transparent with its configurations so that IoC and Factory are not too complicated to implement... Now I have ...
0
votes
1answer
596 views

Using Laravel with DAO instead of Eloquent ORM

We have a complicated ERP software written in native PHP and our own micro-framework which uses big and complicated queries. We want to rewrite the application using an MVC framework (e.g. Laravel). ...
1
vote
1answer
141 views

Optimal strategy for pushing data to DB for repeat updates, considering only a fraction of records change values

Millions of position data is coming in a system which needs to be stored in a database. The data comes in pipe delimited formats in flat files,on a regular basis say twice a day. And most importantly ...
4
votes
3answers
5k views

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 ...
2
votes
1answer
143 views

Multiple CRUD oriented DAO, but need some kind of large data join

At work I was assigned a task to investigate on the severe slowness of an application I am not familiar with. Simple requests were taking several minutes to resolve. Here's how it was before (...
6
votes
1answer
370 views

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 ...
2
votes
0answers
67 views

Pattern for retrieving batches of Objects?

This seems to be a recurring requirement for me, so I'd like to get some feedback on how to implement it and what sort of test code makes sense. I need to retrieve batches of data and stitch it ...
6
votes
2answers
517 views

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 ...
1
vote
2answers
431 views

Making DAO's independent on each other

I have these two classes (Getter/Setter/Constructor omitted): public class Company { private String name; private String adress; private List<Employee> employees; private Uuid ...
3
votes
2answers
2k views

RESTful service and DAO: deciding on responses

I am developing a RESTful API and I am using DAOs to serve data to the service. I am having trouble deciding where certain responsibilities should fall, whether in the service or in the DAO contract. ...
9
votes
3answers
10k views

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 ...
0
votes
0answers
270 views

DAOs - As a separate package or encapsulated in Service itself?

This question is to understand the pros & cons for keeping the DAO's with the service or as a separate package being consumed by the services. Consider a micro-service architecture. Let's say I ...
3
votes
1answer
179 views

Is it good practice to access database in mapping between object

Situation I receive message from a 3rd party, and these messages are use to create or update database information. Message and data to be updated can be de-serialize in object form, but are not ...
0
votes
1answer
910 views

Generate id in application or use database generated one?

I am writing a small app that manages a couple of recipes. I have a MySQL database that is used by my data persistance layer. I need some kind of id in my business objects representing the recipes to ...
0
votes
2answers
286 views

How to use DAO effectively in my MMO server

I am working on a small multi player game for my final year project and currently working on the server. It's a Tank Battle game and have two main entities which I will use on the server side which ...
3
votes
3answers
734 views

How to see Entity Framework code with ASP.NET MVC from a software architecture viewpoint?

Let's say I'm starting a Web Application project that uses a) ASP.NET MVC b) Entity Framework In terms of Software ARchitecture, correct me if I'm wrong, -1) Could I place all my Entity Framework ...
3
votes
2answers
967 views

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, ...
1
vote
1answer
834 views

Consuming a rest API that exposes nested objects

I have a series of nested objects, exposed over a REST API, like so: class Categories { int id; string name; List<Subcategories> subcategories; } class Subcategories { ...
6
votes
2answers
10k views

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 ...
1
vote
2answers
761 views

Implementing a NoSQL and RDBMS compatible DAO

What would be the correct way to design a DAO which implementation is first going to be targeting a MS SQL database with a STAR model, but yet, business requirements specify the application must be ...
3
votes
2answers
2k views

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 ...
2
votes
1answer
2k views

Producing JSON objects from JPA entities in REST API

I have a REST service producing JSON and consuming JSON. A lot of this are simple CRUD operations. My initial idea was to simply use the DAOs directly in the controller: @ResponseBody() @...
1
vote
0answers
603 views

Transaction Management in Hibernate with DAO Design Pattern

I have many Tables, For every Table,we have DAO Interface and DAOImplementation class. Example DAO Interface public interface CancelPolicyDAO { public CancelPolicy insertCancelPolicy(CancelPolicy ...
18
votes
3answers
20k views

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 ...
-1
votes
2answers
282 views

Data Access Objects old fashioned? [closed]

A couple of weeks ago I delivered some work for a university project. After a code review with some teachers I got some snarky remarks about the fact that I was (still) using Data Access Objects. The ...
0
votes
1answer
594 views

Spring JDBC Template without DAO?

I am rather new to writing applications that interact with databases, and I'm curious about a project I'm working on. I have to write a very simple web app which is going to be displaying metric data ...
3
votes
1answer
2k views

Thoughts on refactoring a generic DAO

I have designed a generic DAO in Java and am having confusion about whether to refactor it to different design or not. PS Don't say to use already existing 3rd person framework. I know there are some ...
4
votes
2answers
3k views

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'...
2
votes
2answers
2k views

Does 'consider returning Null Object' apply to a DAO read method?

I was looking for an answer to the question of what a DAO should return when a search ends up to be for an entity that does not exist. There are some generic previous questions related to returning ...
1
vote
0answers
185 views

DAO Design with Child Objects

If I have objects that represent a hierarchy of relationships. For example: Person   Spouse     Spouse Contact     Spouse Address   ...
4
votes
1answer
3k views

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....
3
votes
2answers
647 views

java classes and database queries

Can someone please explain the best way to solve this problem. Suppose I have three classes Person Venue Vehicle I have a DAO method that needs to return some or all of these attributes from each ...
6
votes
3answers
3k views

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 ...
10
votes
3answers
46k views

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 , ...
0
votes
3answers
485 views

Reuse the data CRUD methods in data access layer, but they are updated too quickly

I agree that we should put CRUD methods in a data access layer, However, in my current project I have some issues. It is a legacy system, and there are quite a lot CRUD methods in some concrete ...
12
votes
3answers
24k views

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 ...
3
votes
2answers
688 views

Replacing dao layer

I am developing a series of webservices (based on spring and spring mvc). For the first time in my dev career I do plan on replacing the dao layer in the future(I have always seen it mentioned but ...