I am looking into persisting my model using Hibernate. I seem to find two approaches to do this.
The first one is using SessionFactory
, for example:
Merely you can find description for these annotations on the Spring docs site.
Shortly, to answer your questions the difference between them is they are used for different purposes.
@Transactional is used to demarcate code involved into transaction. It's placed on classes and methods.
@Repository is used to define a Spring bean that support transactions, it can be used in DI as well.
They can be used both on the same class.