what is the purpose and activity of SessionFactory in
hibernate?

Answers were Sorted based on User's Feedback



what is the purpose and activity of SessionFactory in hibernate?..

Answer / pranay bhawsar

The SessionFactory is created from a Configuration object, and as its name implies it is a factory for Session
objects.
 
The SessionFactory is an expensive object to create. It, like the Configuration object, is usually created during
application start up. However, unlike the Configuration object, It should be created once and kept for later
use.

The SessionFactory object is used by all the threads of an application. It is a thread safe object. One
SessionFactory object is created per database. Multiple SessionFactory objects (each requiring a separate
Configuration) are created when connecting to multiple databases. The SessionFactory can also provide
caching of persistent objects.

The main use of session factory object is to get the session object for the application.

Is This Answer Correct ?    71 Yes 11 No

what is the purpose and activity of SessionFactory in hibernate?..

Answer / srikanth

To Create Session object to use hibernate in an
application SessionFactory is required.
When buildSessionFactory()method is called hibernate
decides about various sql statements,that has to be used to
access various tables and creates SeessionFactory object.
This operation is expensive and it should be used only once.

Is This Answer Correct ?    54 Yes 20 No

what is the purpose and activity of SessionFactory in hibernate?..

Answer / yograj pandey

SessionFactory is Hibernate's 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();

Is This Answer Correct ?    28 Yes 6 No

what is the purpose and activity of SessionFactory in hibernate?..

Answer / ram nidadavolu

Application obtains session instances from Session Factory.
Only single SessionFactory for the whole application.

SessionFactory caches generate SQL statements and other
mapping metadata that Hibernate uses at runtime.

Cached data that has been read in one unit of work and may
be reused in a future unit of work.

SessionFactory sessionFactory =
Configuration.buildSessionFactory();

Is This Answer Correct ?    29 Yes 20 No

what is the purpose and activity of SessionFactory in hibernate?..

Answer / jadab

The SessionFactory is created from a Configuration object, and as its name implies it is a factory for Session objects.The SessionFactory is an expensive object to create. It, like the Configuration object, is usually created during application start up. However, unlike the Configuration object, It should be created once and kept for later use.The SessionFactory object is used by all the threads of an application. It is a thread safe object. One SessionFactory object is created per database. Multiple SessionFactory objects (each requiring a separate Configuration) are created when connecting to multiple databases. The SessionFactory can also provide caching of persistent objects.The main use of session factory object is to get the session object for the application.

Is This Answer Correct ?    3 Yes 1 No

what is the purpose and activity of SessionFactory in hibernate?..

Answer / rajan

To Create Session object to use hibernate in an
application SessionFactory is required.
When buildSessionFactory()method is called hibernate
decides about various sql statements,that has to be used to
access various tables and creates SeessionFactory object.
This operation is expensive and it should be used only once.

Is This Answer Correct ?    8 Yes 7 No

what is the purpose and activity of SessionFactory in hibernate?..

Answer / soumya ranjan

The main contract here is the creation of Session instances. Usually an application has a single SessionFactory instance and threads servicing client requests obtain Session instances from this factory.

The internal state of a SessionFactory is immutable. Once it is created this internal state is set. This internal state includes all of the metadata about Object/Relational Mapping.

Implementors must be threadsafe.

Is This Answer Correct ?    1 Yes 1 No

what is the purpose and activity of SessionFactory in hibernate?..

Answer / pvc

Configure() is used for the parsing the xml file.It will
used the DOM Parser for parsing

Is This Answer Correct ?    5 Yes 8 No

what is the purpose and activity of SessionFactory in hibernate?..

Answer / ankur

Configuration object is used to create a SessionFactory object which inturn configures Hibernate for the application using the supplied configuration file and allows for a Session object to be instantiated. The SessionFactory is a thread safe object and used by all the threads of an application.

The SessionFactory is is heavyweight object so usually it is created during application start up and kept for later use. You would need one SessionFactory object per database using a separate configuration file. So if you are using multiple databases then you would have to create multiple SessionFactory objects.

Is This Answer Correct ?    2 Yes 5 No

what is the purpose and activity of SessionFactory in hibernate?..

Answer / madhan kumar

Session factory is used to access the various tables.it is
expensive and it should be used only once.

Is This Answer Correct ?    3 Yes 7 No

Post New Answer

More J2EE Interview Questions

how dopost is secured than doget?

4 Answers   CGI,


Sapient Interview Questions

8 Answers   Sapient, TCS,


What are the four components of j2ee application?

0 Answers  


Describe orm?

0 Answers  


What is connector?

0 Answers  






What is wildfly java?

0 Answers  


What is java 2 platform, standard edition (j2se)?

0 Answers  


Why is java considered dynamic?

0 Answers  


Is j2ee and jee same?

0 Answers  


How do you make a class immutable in java?

0 Answers  


What is javafx java?

0 Answers  


Hi Friends. I want complete technical flow of j2ee project with following technologies. jsp , servlet , Struts , Hibernate , (should follow mvc-2 design pattern) . with DAO ,DTO SERVICE layers .

0 Answers   Infosys,


Categories