Aniket
Aniket

Reputation: 33

DAO implementation in java

When we create Data Access Object layer in java, we declare methods for insert,update and delete data. Should we use synchronization for these methods?? Because i think lots of users can save,update and delete data at the same time.

Please help.

Upvotes: 1

Views: 351

Answers (1)

No, because your DAO itself should be stateless. The various users' operations should be coordinated using database transactions, not JVM synchronization.

(And if practical, you should avoid writing DAOs in the first place, if some tool such as Spring Data can autogenerate them for you.)

Upvotes: 2

Related Questions