0

While learning the Dao layer I come up with a doubt.

In real time web application, multiple users may access same db in same time, in that case whether synchronize method or block need to be used? if possible can you share sample code dao for handling multiple user application

I referred below link :

http://ramj2ee.blogspot.com/2013/08/data-access-object-design-pattern-or.html#.Voeh3Wxuldh

Data access object (DAO) in Java

Community
  • 1
  • 1
needreebas
  • 71
  • 2
  • 9
  • Transactions are design for concurrent handling using locks or time stamps. also in web based application you can use cookies and sessions . – Nipun Alahakoon Jan 02 '16 at 12:01

1 Answers1

0

You should use transactions. Preferably, use an existing DAO system such as JPA (Hibernate) that already supports all of that. I personally also prefer using Spring for handling transactions with the @Transactional annotation and Spring Data repositories, which autogenerate queries for me, but there are multiple approaches to controlling the transaction scope.

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152