Spring Transactions with Hibernate and SQL best practice?

BernateTemplate is indeed not very useful, and the Spring doc advises considering not to use it anymore.

BernateTemplate is indeed not very useful, and the Spring doc advises considering not to use it anymore. @Repository and @Service basically do the same thing, except (AFAIK) two things: @Repository makes it clear that the service is a DAO, and not a business service exceptions thrown from an @Repository annotated service are translated to Spring's persistence exception classes. This means that you won't get but Spring exceptions wrapping .

1 Seems that going the explicit Dao interface and implementation route with @Repository seems to be the better way. – Nico Huysamen Nov 24 at 10:38.

Bernate Template was needed when hibernate did not supported the notion of having one session per thread. Now the better approach is to use getCurrentSession method on SessionFactory directly. With bernateTemplate the other issue is that if there are newer api's exposed on SessionFactory then one has to wait for the new release of bernate Template to support that.In a nutshell, use SessionFactory directly.

The usage of bernateTemplate is discouraged in the bernateTemplate documentation at static.springsource.org/spring/docs/2.0.... NOTE: As of 0.1, transactional bernate access code can also be coded in plain Hence, for newly started projects, consider adopting the standard bernate3 style of coding data access objects instead, based on SessionFactory. GetCurrentSession(). (Spring's LocalSessionFactoryBean automatically supports Spring transaction management for the bernate3 getCurrentSession() method.) The usage of @Repository or @Service does not make any difference but I believe that these annotations would have further DAO/Service level support in the future which would make their usage more precise.

I personally prefer the usage if @Repository in the DAO layer to demarcate my service and business layers.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions