Reputation: 1427
I have a project that uses hibernate and the startup time is very long, I was wondering if it is possible to serialize the EntitiyManagerFactory and thus only first startup would be slow.
Upvotes: 0
Views: 102
Reputation: 596996
It can be serialized in hibernate (not necessarily the case in other JPA implementations), because the hibernate internal interface extends Serializable
. But this is for internal use, probably by the application server to be able to passivate it somehow.
Your problem lies somewhere else and should not be solved by serializing the entity manager factory. Usually on startup it creates a connection pool and fills it with fresh database connections. And you can't serialize these connections, so a whole slew of new problems will appear if you go that way.
Instead, make sure the database is responding timely (if not - it is slowing the filling of the pool), and whether your startup is really that slow. 30 seconds is not slow, 5 minutes might be slow, depending on the size of the appplication.
Upvotes: 2