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
9
votes
1 answer

How do I build a GenericDao using QueryDSL?

First of, I am really new to QueryDSL. I'm using a Spring + Hibernate environment. The problem I'm facing is with building a GenericDAO to implement all the basic CRUD operations, but I'm not sure how do I get the static reference from a QEntity. My…
9
votes
3 answers

Spring JDBC: How to create the tables?

I am using Spring JdbcTemplate with the DAO pattern to access a database. Instead of creating the database tables manually, I am looking for a way to generate the tables in the DAO layer. I understand that I can use the JdbcTemplate to execute…
Juri Glass
  • 88,173
  • 8
  • 33
  • 46
9
votes
2 answers

Adding and updating entities with Entity Framework

In my last project I have used Entity Framework 5 Code First. I completed my project but had a lot of pain during the development process. I tried to explain my pain below: I had several data classes in my data access logic layer like Product,…
Furkan
  • 683
  • 2
  • 10
  • 26
9
votes
1 answer

Angular.js and DAO pattern

First of all I must admit I am quite new to Angular.js and I haven't used any new generation js framework like Backbone or Knockout before. I'm creating an application which communicates with server using RESTful API. I dug a lot into angular…
Mequrel
  • 727
  • 6
  • 12
9
votes
2 answers

MS Access Batch Update via ADO.Net and COM Interoperability

This is kind of a follow-up to this thread. This is all with .Net 2.0; for me, at least. Essentially, Marc (OP from above) tried several different approaches to update an MS Access table with 100,000 records and found that using a DAO connection was…
Karter
  • 225
  • 4
  • 10
8
votes
2 answers

Unit testing hibernate daos with spring

I like to write JUnits for my hibernate dao implementations and seek opinion on the suggested approach for writing these unit testcases. I can think of two strategies. Mocking hibernate template using a library like EasyMock and testing just the…
Siva
  • 1,357
  • 1
  • 10
  • 12
8
votes
4 answers

Java Framework for Database operations

At my work place, we use DAO pattern to hancle any sort of database operation. It hides bulky statements from programmer. Programmers need to write sql query and logic to handle output data. BaseDao handles all sort of operation and return output in…
Amit Kumar Gupta
  • 7,193
  • 12
  • 64
  • 90
8
votes
2 answers

Android Room Generic DAO

Good day Stack, i'm working on an Android project that uses Android's Room 1.0.0 Alpha 5, the main issue that i'm facing is that every time i need to call one of the DAO from room i need to do something like this: Activity.java: ... AppDatabase db =…
Basher SG
  • 167
  • 1
  • 8
8
votes
1 answer

EasyMock returns Null for Expected Method

I have am having a problem with EasyMock returning null for an expected (defined) method call. Creation of the mocked Object mock = EasyMock.createMock(DAO.class); Mock Set up in unit…
Seth M.
  • 598
  • 2
  • 4
  • 14
8
votes
3 answers

DAO with Null Object Pattern

After Reading: Effective Java (See Item 43) - Joshua Bloch Clean Code (Don't Return Null) - Uncle Bob Avoiding != null statements Null Object pattern I was looking for an answer to the question of what a DAO should return when a search ends up…
Ye Win
  • 2,020
  • 14
  • 21
8
votes
2 answers

Is it OK to have singleton DAO objects?

Consider the following classes' structure: BaseDAO with methods to crest PreparedStatement and get connection from pool AccountDAO extends BaseDAO to work with Account table via JDBC. This class is singleton AccountService witch calls methods of…
Ada
  • 81
  • 1
  • 2
8
votes
7 answers

generic DAO in java

I am trying to develop generic DAO in java. I have tried the following. Is this a good way to implement generic DAO? I don't want to use hibernate. I am trying to make it as generic as possible so that I don't have to repeat the same code over and…
akshay
  • 111
  • 1
  • 2
  • 4
8
votes
4 answers

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 cpdao)throws ChannelDispatcherException; public…
LMK
  • 2,882
  • 5
  • 28
  • 52
8
votes
2 answers

What is the difference between POJO and DAO

May I know what is the difference between POJO (Plain old java object) and DAO (Data access object) in Java. Where to use which one? From the Jboss hibernate tutorial…
Rajesh Kumar
  • 1,270
  • 4
  • 15
  • 31
8
votes
4 answers

How to detect the last insert ID within a transaction in Yii using DAO?

That's the source code, I need to detect the ID (see the marked position between the two queries below). $connection = Yii::app()->db; $transaction=$connection->beginTransaction(); try { $q = "INSERT INTO `someTable1` .... "; …
user3702874
  • 83
  • 1
  • 3