What is this spring.jpa.open-in-view=true property in Spring Boot?

ghz 1years ago ⋅ 6667 views

Question

I saw spring.jpa.open-in-view=true property in Spring Boot documentation for JPA configuration.

  • Is the true default value for this property if it's not provided at all?;
  • What does this really do? I did not find any good explaining for it;
  • Does it make you use SessionFactory instead of EntityManagerFactory? If yes, how can I tell it to allow me to use EntityManagerFactory instead?

Thanks!


Answer

This property will register an OpenEntityManagerInViewInterceptor, which registers an EntityManager to the current thread, so you will have the same EntityManager until the web request is finished. It has nothing to do with a Hibernate SessionFactory etc.