Spring Hibernate - difference between CrudRepository and SessionFactory

后端 未结 1 1431
终归单人心
终归单人心 2021-01-06 23:21

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:

1条回答
  •  借酒劲吻你
    2021-01-07 00:09

    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.

    0 讨论(0)
提交回复
热议问题