adspace
What is different between session and sessionfactory in hibernate? (Detailed answer)
Answer Posted / 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 View All Answers