Search code examples
javaspringjpaspring-bootspring-data

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


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!


Solution

  • 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.