2
2
.
.
2
2
.
.
2
2
D
D
a
a
t
t
a
a
A
A
c
c
c
c
e
e
s
s
s
s
O
O
b
b
j
j
e
e
c
c
t
t
(
(
D
D
A
A
O
O
)
)
I
I
n
n
f
f
o
o
Repository Object and DAO are synonyms. (in Spring Boot where they refer to the same thing)
DAO stands for Data Access Object (Class/Object that is used to store and retrieve data)
Repository
contains methods for accessing database (for storing and retrieving data)
contains Entity Property (which contains actual data that should be stored or was retrieved)
Term Repository might be misleading since generally repository means "a place where something is stored".
In contrast Repository Object is not "a place where something is stored".
Instead it is a collection of Methods that are used to communicate with "a place where something is stored".
Having this in mind DAO as Data Access Object represents the purpose of this Object much better.
Because it says it is something that allows you to access data and not "a place where data is stored".
Some use DAO instead of Entity by having Entity Properties, Setters and Getters inside DAO itself.
This way DAO is used to both represent DB Table/Record and to encapsulate Methods for communicating with DB.
In Spring Boot we will have clear distinction between Entity and Repository (DAO).