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

DAO design pattern

So lets say we have a couple of entities we want to persist using DAO objects. So we implement the right interface so we end up with class JdbcUserDao implements UserDao{ //... } class JdbcAddressDao implements AddressDao{ //... } So if I want to…
Mercurial
  • 2,095
  • 4
  • 19
  • 33
13
votes
13 answers

Simple CRUD Generator for C#

I am looking for a simple CRUD (or DAL) Generator for C#. I don't want anything heavyweight since I only have a couple of tables in a SQL Server 2008 database. Any suggestions? I know .netTiers, but it is way too much for what I…
Martin
  • 39,309
  • 62
  • 192
  • 278
13
votes
3 answers

Unit testing a DAO class that uses Spring JDBC

I have several DAO objects that are used to retrieve information from a database and I really want to write some automated tests for them but I'm having a hard time figuring out how to do it. I'm using Spring's JdbcTemplate to run the actual query…
Alex Ciminian
  • 11,398
  • 15
  • 60
  • 94
13
votes
2 answers

DDD: Where to put persistence logic, and when to use ORM mapping

We are taking a long, hard look at our (Java) web application patterns. In the past, we've suffered from an overly anaemic object model and overly procedural separation between controllers, services and DAOs, with simple value objects (basically…
optilude
  • 3,538
  • 3
  • 22
  • 25
13
votes
5 answers

Recommended structure for high traffic website

I'm rewriting a big website, that needs very solid architecture, here are my few questions, and pardon me for mixing apples and oranges and probably kiwi too:) I did a lot of research and ended up totally confused. Main question: Which approach…
CodeVirtuoso
  • 6,318
  • 12
  • 46
  • 62
13
votes
1 answer

Design Patterns for Data Access Layer

I have an application which uses a database (MongoDB) to store information. In the past, I have used a class full of static methods to save and retrieve data but I have since realised this is not very object-oriented or future-proof. Even though it…
user2248702
  • 2,741
  • 7
  • 41
  • 69
12
votes
4 answers

DAO and Service?

I'm always facing a problem where I can't really think of service object encapsulating many DAO methods. I mean that for my servlet sometimes it is sufficient to use single DAO method, for example addUser(User params). What is better to do - to…
Aubergine
  • 5,862
  • 19
  • 66
  • 110
12
votes
2 answers

DAO and JDBC relation?

I know that Hibernate implements ORM (Object Relational Mapping), what type of mapping does JDBC implement? Does it implement DAO? I don't totally understand how/if DAO is related to JDBC...?
rrazd
  • 1,741
  • 2
  • 32
  • 47
12
votes
4 answers

DAO / repository: Good practice return value after insert / update

Although probably a trivial question, I've always wondered about this. Usually, after insertion into the db, it seems common practice to return the id of the business entity. @Override public Long createUser(UserEntity user) { …
html_programmer
  • 18,126
  • 18
  • 85
  • 158
11
votes
1 answer

How To Create Generic Data Access Object (DAO) CRUD Methods with LINQ to SQL

I am new to LINQ to SQL and attempting to create a generic Data Access Object (DAO) for the basic Create, Read, Update, and Destroy (CRUD) methods so that I can reuse the code. I was successful in creating a generic method that will delete any…
Grasshopper
  • 4,717
  • 9
  • 36
  • 62
11
votes
2 answers

Automatic Hibernate Transaction Management with Spring?

How far does the spring framework go with transaction handling? My reading of the book "Spring In Action" suggestions with its examples that you create DAO methods that don't worry about Session and Transaction management fairly simply by setting up…
James McMahon
  • 48,506
  • 64
  • 207
  • 283
11
votes
6 answers

DAO generator for java

I'm searching for free and simple DAO generator for java (it needs to create entities/bens from db tables/views and generate basic CRUD code). Currently, I`m using DAO4J which lacks some functionality like views mapping. I know that there are…
Ivan Milosavljevic
  • 839
  • 1
  • 7
  • 19
11
votes
1 answer

Spring session-scoped beans as dependencies in prototype beans?

I read spring docs on this subject several times, but some things are still unclear to me. Documentation states: If you want to inject (for example) an HTTP request scoped bean into another bean, you must inject an AOP proxy in place of the scoped…
Less
  • 3,047
  • 3
  • 35
  • 46
11
votes
1 answer

Optional query parameters for Android Room

I have the following DAO with a query: @Dao public interface BaseballCardDao { @Query( "SELECT * FROM baseball_cards " + "WHERE brand LIKE :brand " + " AND year = :year " + " AND number LIKE :number " + …
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
11
votes
3 answers

Room - check if data were fetched recently

In official Guide to App Architecture is an exaple of repository. There is a check if an object is existing in database and if is fresh: // check if user was fetched recently boolean userExists = userDao.hasUser(FRESH_TIMEOUT); Any ideas how to…