What is different between session and sessionfactory in hibernate? (Detailed answer)



What is different between session and sessionfactory in hibernate? (Detailed answer)..

Answer / Manoj Kalyani

Session and SessionFactory are two key components of the Hibernate API:
1. Session: It represents a single open session with the database, managing a single unit of work. Each session is bound to a specific transaction. A session can be used to save, update, delete, or query data in the database.
2. SessionFactory: It manages multiple sessions and configurations for your application. A SessionFactory instance is created once during application startup and shared across all sessions throughout the application's lifetime. The SessionFactory loads mapping metadata and prepares SQL statements to be used by each session as needed.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Hibernate Interview Questions

What is a hibernate transaction?

1 Answers  


What is a hibernate xml mapping document and how does it look like?

1 Answers  


What is transaction boundary in hibernate?

1 Answers  


How create hibernate cfg xml?

1 Answers  


How to implement joins in hibernate?

1 Answers  


What are different states of an entity bean in hybernate?

1 Answers  


What is bidirectional flow?

1 Answers  


What databases does hibernate support?

1 Answers  


What is mapping in hibernate?

1 Answers  


What is hbm2ddl in hibernate?

1 Answers  


How do I save in hibernate?

1 Answers  


What is difference between get and load?

1 Answers  


Categories