简体   繁体   中英

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.

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.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM