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
7
votes
3 answers

Calling one DAO from another DAO?

Can this ever make sense? Say I need to fetch an object from the DB which has a relation to another object (represented by a foreign key in the DB, and by a composition in my domain object). If in my first DAO I fetch the data for object 1, then…
oym
  • 6,983
  • 16
  • 62
  • 88
7
votes
2 answers

Java Generic of Another generic

I have interface: interface Identifable { T getID(); } and class that implement this: public class Cat implements Identifable { public Long getID(){...}; } everything works fine. so far. Now I want to…
Cichy
  • 1,319
  • 3
  • 20
  • 36
7
votes
2 answers

How can one search TableDefs for linked tables?

Looping through a set of TableDefs, how can one determine if each TableDef represents a linked table, as opposed to a local table?
StockB
  • 755
  • 1
  • 13
  • 33
7
votes
1 answer

Avoiding global state in DAO layer of a Clojure application

I'm trying to implement the ideas from http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded into my codebase. I have a dao layer, where I now need to pass in a database in order to avoid global state. One thing that is throwing me off…
ebaxt
  • 8,287
  • 1
  • 34
  • 36
7
votes
2 answers

Why use an MVC framework when Servlets, JSPs and a lightweight DAO layer will work?

I'm finding it difficult to embrace a Java MVC framework, when it looks as if Servlets, JSPs and a lightweight DAO will do just about everything you need it to do in order to decouple the controllers/views/models. For PHP I can see the necessity…
user4903
7
votes
3 answers

Spring MVC Domain Object handling Best Practice

Lets assume a simple Spring MVC Controller that receives the ID of a domain object. The Controller should call a service that should do something with that domain object. Where do you "convert" the ID of the domain object into the domain object by…
Thomas Einwaller
  • 8,873
  • 4
  • 40
  • 55
7
votes
2 answers

DAO Generator Tool with Plain JDBC

I'm looking for a good DAO Generator that build classes with plain JDBC 4 and basic CRUD operations. I have seen that NetBeans generates classes and Java Beans or Entities with JPA and Hibernate. I'm looking for some other tool like this, but I…
Paul Vargas
  • 41,222
  • 15
  • 102
  • 148
6
votes
3 answers

Spring JPA entities not saving to database

I am facing some issues in Spring JPA. I successfully configured the Spring JPA project and am able to run the project without having any exception. I intension to save the entities to the database. But when I am running the project, it is neither…
user414967
  • 5,225
  • 10
  • 40
  • 61
6
votes
2 answers

Access: Get newly created auto number in DAO

I have a code in DAO that connects to a linked table in SQL Server 2008. I need to get the newly created auto number on .AddNew. Set db = CurrentDb Set rs = db.OpenRecordset("AuditTrail") rs.AddNew rs("ActionID") = actionAdd rs("dtDateTime") =…
Rick
  • 2,288
  • 18
  • 66
  • 98
6
votes
2 answers

MyBatis mapper injected directly into service class. What about exceptions?

I'm currently working with MyBatis-Spring integration framework and that's what I read from docs: Rather than code data access objects (DAOs) manually using SqlSessionDaoSupport or SqlSessionTemplate, Mybatis-Spring provides a proxy factory:…
Maciej Ziarko
  • 11,494
  • 13
  • 48
  • 69
6
votes
1 answer

Spring integration test does not roll back

I'm using Spring + Hibernate + H2. I do database operations in my integration tests (by calling a service class). I want Spring to rollback the changes after each test method, but I can't get it to work. At first I used MySQL (with MyISAM, which…
martin
  • 2,150
  • 1
  • 34
  • 48
6
votes
1 answer

Spring Roo: use JPA entity as a DAO

The code below is what Spring Roo generates by default, the EntityManager is injected in your domain model POJOs with the rest of the methods to manage the entity (save, update, delete, findXXX, ...). Maybe it is a more object-oriented approach (in…
Guido
  • 46,642
  • 28
  • 120
  • 174
6
votes
2 answers

Data access object (DAO) in Python Flask SQLAlchemy

Does the Python (Flask) SQL Alchemy uses both DAO and ORM design, or simply just ORM? I am learning design strategies and I thought of SQLAlchemy. Is it considered a DAO (clearly ORM) as well? By default, it does not look like DAO. What if I defined…
6
votes
1 answer

controllers, entity classes or dao - what goes where?

With the introduction of Hibernate in my project, my code started getting really coupled, and boilerplate in many places (and it should be the other way round, right?) I got pretty confused by a particular example. I've always considered DAO objects…
user802232
  • 2,541
  • 7
  • 34
  • 40
6
votes
2 answers

Difference between Model classes and DAO classes

I'm new to java based web applications. I have to create a dynamic web project using MVC structure. So far I created three packages and some java classes like below. I have some doubts about these things Can someone explain the difference between…
kenWay
  • 81
  • 1
  • 6