I'm new to Spring, and I just read the docs on Hibernate-Spring integration (version 3). I don’t understand why automatic transaction management (declarative) is applied to the “service” in the documents, and not to the DAO implementation directly. In particular, I do not understand what they mean for the service, what is the difference compared to the DAO, and if it is really necessary for integrating Hibernate with Spring.
I tried using only the Hibernate DAO Implementation and configured in XML so that the factory session would be established after the instance was created. In any case, this throws exceptions, since Spring does not allow access to transactional hibernation. So, to add transactional access, do I need to add this "service"? How is this different from a simple DAO?
A DAO (Data Access Object) is just a design pattern or the name of the class that implements this pattern.
Service is a (Spring) term for (most single-user) classes that provides some (business) service functions. And this is also the annotation name for declaring a class as a service in Spring.
fixed: repository instead of resource
There are many ways to implement DAO in spring, most of two common shares:
Spring, :
, , , DAO
" ", . "" ( ), : A, B. , . , .
:
transfer(Account to, Account from, double value)
DAO :
updateBalance(Account account, double amount)
transfer updateBalance, .
transfer
updateBalance
Spring, , ( ) Spring , , .
DAO . , , , . , - -.
-. , . . , . , , . , /, , . , DAO.
, DAO. , , , , DAO, . (, SQL, .)
DAO ( , , , DAO, ), DTO.
Transactional services and the DAO can work fine with each other as long as the distribution of transactions in the DAO is properly set. That is, use an existing transaction if it exists, but create a new one if it does not.
Source: https://habr.com/ru/post/1786896/More articles:creating an HTML source introduces a default value in tinyMCE - tinymcewhich is faster than 5 + 5 + 5 + 5 + 5 or 5 * 5? - javaPoor performance (stuttering) with Windows Phone 7 Page Transitions - performancehow to install ndk (linux)? - androidSustained request per second [QPS] without timeout errors - google-app-enginedelete double lines in a line - stringБиблиотека стека в стиле OpenGL для as3 - apiКакой из следующих SQL-запросов будет быстрее? Присоединение к двум таблицам или последовательным запросам? - sqlЯ создал эшафот в рельсах под названием Cove. В контроллере переменная экземпляра автоматически называется @cofe. Почему это происходит? - ruby-on-railsJSLint: I can't reassure him with a space in the expression "var" - jslintAll Articles