java - When should we close the EntityManagerFactory? -
I am very new at ORM. I am just starting to read books and documents about the Java Integration API with being in hibernation.
I was just wondering, Is EntityManagerFactory close to closing jdbc database connection?
Should we stop it every time we release / update / delete or stop? If we do not turn it off, will the database connection be opened?
I was just wondering, closed
EntityManagerFactoryjdbc database connection Is it like closing?
This is not perfect, but close to EntityManagerFactory will be close to eliminating a whole connection pool. If you want to consider a JDBC connection, then you should think of EntityManager .
Should we stop it every time I release / update / delete or stop it? Creating a
EntityManagerFactoryis a very expensive operation and should be done once for the lifetime of the application (youclosethe end of the application In). Therefore, no, you should not turn it off for every continuation / update / removal operation.
EntityManagerFactory is created once for all, and you usually receive a requestEntityManager, which closes at the end of the request (which is actually linked to a A database connection and in fact closed theIf we do not turn it off, will the database connection open? P>
As indicated as this, Code> EntityManager
EntityManagerrelease JDBC connection That time, return it to the pool).
Comments
Post a Comment