Hibernate SessionFactory vs. JPA EntityManagerFactory

后端 未结 8 2285
清歌不尽
清歌不尽 2020-11-27 09:03

I am new to Hibernate and I\'m not sure whether to use a Hibernate SessionFactory or a JPA EntityManagerFactory to create a Hibernate Session

8条回答
  •  囚心锁ツ
    2020-11-27 09:29

    Using EntityManagerFactory approach allows us to use callback method annotations like @PrePersist, @PostPersist,@PreUpdate with no extra configuration.

    Using similar callbacks while using SessionFactory will require extra efforts.

    Related Hibernate docs can be found here and here.

    Related SOF Question and Spring Forum discussion

提交回复
热议问题