Questions tagged [dao]

A Data Access Object (DAO), is a design pattern in object-oriented software design, creating an object that provides an abstract interface to some type of database or other persistence mechanism.

A data access object (DAO) is an object that provides an abstract interface to some type of database or persistence mechanism, providing some specific operations without exposing details of the database. It provides a mapping from application calls to the persistence layer.

Source: Wikipedia (retrieved version)

More details: - Core J2EE Patterns - Data Access Object

2621 questions
28
votes
2 answers

How do I implement a DAO manager using JDBC and connection pools?

My problem is as follows. I need a class that works as a single point to a database connection in a web system, so to avoid having one user with two open connections. I need it to be as optimal as possible and it should manage every transaction in…
Carlos Vergara
  • 3,592
  • 4
  • 31
  • 56
27
votes
8 answers

Pros and cons of the use of the DAO pattern

As I mention in the title, I'm interested to know what you (as experienced developers) think about the use of the DAO pattern, specifically within a web application. What advantages have you found and what consequences of its use have you disliked?
Sheldon
  • 2,598
  • 10
  • 27
  • 36
26
votes
5 answers

DAO Unit testing

I have been looking at EasyMock and tutorials/examples around using it for Unit Testing DAO classes, for an "outside container" test. However, I think most of them talk about testing the Service Layer instead, mocking the DAO class. I am a bit…
Dchucks
  • 1,189
  • 5
  • 22
  • 48
26
votes
4 answers

Handling Dao exceptions in service layer

If my Dao layer throws Dao specific exceptions, then does handling them in my service layer consitute a leakage of concerns? If yes, then should I make the exceptions generic and independent of any layer to address it, or is there some other way?…
shrini1000
  • 7,038
  • 12
  • 59
  • 99
26
votes
2 answers

What is the difference between DAL, DTO and DAO in a 3 tier architecture style including with MVC

Recently I was learning about ORM (Object Relational Mapping) and the 3 tier architecture style (presentation,business and data persistence). If I understand correctly, I can separate the data persistence layer into DTO and DAO layer. I would like…
Bálint Pap
  • 498
  • 2
  • 12
  • 23
25
votes
3 answers

Junit to test Spring service and DAO layer

I am working on a Spring application (Spring 3.0) and following layered architecture i.e. Controller -> Service -> DAO layers. I want to write unit test cases for service and DAO layer using Junit. I checked Spring official site and also tried many…
Ajinkya
  • 22,324
  • 33
  • 110
  • 161
25
votes
9 answers

Optional long parameter is present but cannot be translated into a null value

Hi i'm developing on web so i have an ajax function which calling to a controller function which calling to a DAO function (to make changes on DB). I'm getting the exception above in the controller function.. controller…
Erez
  • 502
  • 3
  • 6
  • 17
24
votes
5 answers

DAO pattern - where do transactions fit in?

So I've got this generic DAO thing going on and at face value it appears to be ok. It's basically modeled after the CaveatEmptor sample application from the Hibernate guys. On top of that I have a business layer...the guts of the application. …
Boden
  • 4,149
  • 9
  • 43
  • 56
24
votes
2 answers

Difference between Active Record and DAO?

What's the difference between a Data Access Object and Active Record? They seem to be quite the same, as both built a layer between the application and persistence layer, and abstract away direct database access using SQL queries.
helpermethod
  • 59,493
  • 71
  • 188
  • 276
23
votes
1 answer

handling GWT RequestFactory server error responses

I have a newly coded GWT/GAE app that uses RequestFactory and Editors on the client and a custom Objectify DAO Service on the back. The flush() then persist() paths work fine on success. Client side JSR 303 works as well as can be expected too. My…
Stevko
  • 4,345
  • 6
  • 39
  • 66
23
votes
2 answers

JPA findBy field ignore case

How do I make findByIn search using IgnoreCase of ? I tried to use findByNameIgnoreCaseIn and findByNameInIgnoreCase with no result. DB is Postgresql. @Repository public interface UserRepository { List
Daria Bulanova
  • 547
  • 1
  • 5
  • 16
23
votes
6 answers

Exporting MS Access Forms and Class / Modules Recursively to text files?

I found some code on an ancient message board that nicely exports all of the VBA code from classes, modules and forms (see below): Option Explicit Option Compare Database Function SaveToFile() 'Save the code for all modules to files…
leeand00
  • 25,510
  • 39
  • 140
  • 297
22
votes
3 answers

Difference between ADO and DAO

This is not a question about which is better, but rather a question regarding why they differ functionally. The problem I was running into has been handled, but I am curious as to why this behavior is happening. Background - using Excel vba to pull…
APrough
  • 2,671
  • 3
  • 23
  • 31
22
votes
7 answers

Spring + Hibernate : a different object with the same identifier value was already associated with the session

In my application, which uses Spring and Hibernate, I parse a CSV file and populate the db by calling handleRow() every time a record is read from the CSV file. My domain model: 'Family' has many 'SubFamily' 'SubFamily' has many 'Locus' a 'Locus'…
Ashika Umanga Umagiliya
  • 8,988
  • 28
  • 102
  • 185
22
votes
8 answers

Hibernate Delete Error: Batch Update Returned Unexpected Row Count

I wrote this method below that is suppose to delete a member record from the database. But when I use it in my servlet it returns an error. MemberDao Class public static void deleteMember(Member member) { Session hibernateSession =…
Kid Diamond
  • 2,232
  • 8
  • 37
  • 79