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
21
votes
2 answers

Service and DAO vs MVC

I am literally very new to Design Patterns, and I constantly come across words like Service Layers, DAO Layers & Model-View-Controllers in Programming. As StackOverflow is extremely awesome platform having many extremely talented audience when it…
Adil
  • 817
  • 1
  • 8
  • 27
20
votes
5 answers

DAO pattern and model objects

I have looked up a lot of information about the DAO pattern and I get the point of it. But I feel like most explainations aren't telling the whole story and by that I mean where would you actually use your DAO. So for example if I have a User class…
Tom
  • 613
  • 2
  • 6
  • 9
20
votes
2 answers

Hibernate - difference between annotations and commons-annotations?

To keep it short and sweet: There is hibernate-commons-annotations 4.1.0-Final and hibernate-annotations 3.5.6-Final. I'm a nub, what's the difference between them, and do I need them both? Trying to "avoid" JPA and by that I mean using the JPA 2.0…
Sam Levin
  • 3,326
  • 7
  • 30
  • 44
20
votes
4 answers

Is there a way to change the JPA fetch type on a method?

Is there a way to change the JPA fetch type on a single method without editing the entity object? I have a shared ORM layer consisting of JPA entity classes. This ORM layer is accessed by two DAO layers. One DAO needs lazy fetching, as it is for my…
James McMahon
  • 48,506
  • 64
  • 207
  • 283
19
votes
6 answers

How can you check for null in a VBA DAO record set?

I have an optional field in a database that I'm pulling out using a DAO Record Set. I need to check whether or not the field is set before I concatenate it with other fields. So far I have the following code snippet which I've tried with both Is…
Tim Visher
  • 12,786
  • 16
  • 58
  • 66
19
votes
3 answers

Is the DAO Pattern Widely Used in .NET?

Is the DAO—Data Access Object—a commonly used pattern in .NET? I've always used DAOs as a way to provide access to my data layer. For example I might have a thin interface over my EntityFramework ObjectContext exposing all of my ObjectSets as…
Adam Rackis
  • 82,527
  • 56
  • 270
  • 393
19
votes
1 answer

DAO & BO (data access layer) - architecture

I'm a little bit confused about an example found on the web - spring & hibernate (point 4. Model & BO & DAO). There are Model, DAO and BO classes (+ DAO and BO interfaces). What I do not clearly understand is why DAO and BO are separated into…
ducin
  • 25,621
  • 41
  • 157
  • 256
18
votes
6 answers

What unit test to write for a class using generics in Java?

Taking the very specific example of the JpaDao class defined in this article: public abstract class JpaDao implements Dao { protected Class entityClass; @PersistenceContext protected EntityManager entityManager; …
Sébastien Le Callonnec
  • 26,254
  • 8
  • 67
  • 80
18
votes
6 answers

How to create multiple database connections for different databases in java

I have an application which uses four databases in different geographical locations. All the databases contains same tables and only the database name is different according to the location. I have to create some reports in my application which uses…
Harsha
  • 3,548
  • 20
  • 52
  • 75
17
votes
2 answers

Can a DAO call DAO?

I have component which needs to update the database for the customer and customer address (via JDBC). Is it appropriate to call the CustomerAddressDAO from the CustomerDAO? Or create a separate "CustomerDataManager" component which calls them…
Jack BeNimble
  • 35,733
  • 41
  • 130
  • 213
17
votes
6 answers

Hibernate 5.2 version -> A lot of Query methods deprecate?

I'm new to Hibernate. I'm trying to get a list of first name and last name of all administrators. There are two warnings in my following code. I already tried to search a lot online. 1) Query is a raw type. References to generic type Query should be…
Chenya Zhang
  • 463
  • 3
  • 11
  • 22
17
votes
3 answers

Best practice for DAO pattern?

I've seen a lot of codes use a service-dao pattern , I don't know the origin of this pattern . It force the front layer call service , then delegates some of the service task to dao. I want to ask : Does DAO layer do purely data access related…
Sawyer
  • 15,581
  • 27
  • 88
  • 124
17
votes
3 answers

Android: access SQLite database via Content Provider or implement DAO?

I'm wondering which is the best approach to access my application database: use a Content Provider, or implement my DAO by hand? From my latest investigations, seems that Content Provider, even for app internal use, is preferable, but I don't know…
user1135437
  • 303
  • 1
  • 2
  • 8
17
votes
6 answers

How to get file extension of file as a result of sql query?

I have a table named datas and I'm executing a query like this: SELECT linkurl AS DOWNLOADURL, lastrevlevel AS VERSION, code AS DESCRIPTION, created AS RELEASEDATE, name AS TYPE FROM datas WHERE id IN (SELECT child_id …
anto
  • 315
  • 3
  • 9
  • 18
16
votes
9 answers

Hibernate using multiple databases

Someone know how to add a another datasource in hibernate configuration and how to configure Spring to that datasource its autoinject in my respective DAO? This is my code with one datasource, that run perfectly, but i don't know how add another…
richardhell
  • 969
  • 2
  • 10
  • 22