I am new to Spring and I was just reading the docs about Hibernate-Spring integration (version 3). I don’t get why the automatic transaction management (the declarative one) is applied to a “service” in the docs, instead to the DAO implementation directly. In particular I don’t get what do they mean by service, what’s the difference compared to a DAO and if this is really needed to provide Hibernate integration with Spring.
What I tried to do was to use just a Hibernate DAO Implementation and configure in XML to have the session factory set upon instantiation. Anyway, that throws exceptions, because Spring doesn’t allow for non transactional hibernate access. So in order to add transactional access, do I have to add that “service” thing? How has that to be different from the simple DAO?
DAO (Data Access Object) is only a design pattern or the name of the class that implment this pattern.
Service is a (Spring) term for an (most singleton like) class that provides some (business) service functionality. And it is also the name of an Annotation to declare an class as a service in Spring.
corrected: Repository instead of Resource
In spring there are many ways to implment a DAO, the most two commons are: