1.

What Is A Sessionfactory? Is It A Thread-safe Object?

Answer»

SESSIONFACTORY is Hibernates concept of a single DATASTORE and is threadsafe so that many threads can ACCESS it concurrently and request for sessions and immutable cache of compiled mappings for a single database. A SessionFactory is usually only built once at STARTUP. SessionFactory should be wrapped in some kind of singleton so that it can be easily accessed in an application CODE.
SessionFactory sessionFactory = new Configuration().configure().buildSessionfactory();

SessionFactory is Hibernates concept of a single datastore and is threadsafe so that many threads can access it concurrently and request for sessions and immutable cache of compiled mappings for a single database. A SessionFactory is usually only built once at startup. SessionFactory should be wrapped in some kind of singleton so that it can be easily accessed in an application code.
SessionFactory sessionFactory = new Configuration().configure().buildSessionfactory();



Discussion

No Comment Found