Question 1: What is Hibernate?
- Web framework
- ORM framework
- Database
- JVM tool
Explanation: Hibernate is an Object Relational Mapping (ORM) framework.
This beginner-level Hibernate quiz is designed for learners starting with ORM and Java persistence. It covers Hibernate fundamentals such as ORM concepts, configuration, mappings, annotations, Session, SessionFactory, CRUD operations, and basic interview questions.
Explanation: Hibernate is an Object Relational Mapping (ORM) framework.
Explanation: ORM stands for Object Relational Mapping.
Explanation: Hibernate maps Java objects to relational tables.
Explanation: Hibernate Query Language (HQL) is used in Hibernate.
Explanation: hibernate.cfg.xml contains Hibernate configuration.
Explanation: Session represents a single unit of work.
Explanation: SessionFactory is thread-safe.
Explanation: SessionFactory is used to open Sessions.
Explanation: save() stores the object in the database.
Explanation: delete() removes a record from the database.
Explanation: @Entity marks a persistent class.
Explanation: @Id defines the primary key.
Explanation: @GeneratedValue auto-generates IDs.
Explanation: @Table maps class to DB table.
Explanation: @Column maps fields to table columns.
Explanation: @OneToOne defines one-to-one relationship.
Explanation: @OneToMany defines one-to-many relationship.
Explanation: @ManyToOne defines many-to-one relationship.
Explanation: @JoinColumn defines join columns.
Explanation: First-level cache is enabled by default.
Explanation: Session provides first-level caching.
Explanation: Second-level cache is shared.
Explanation: Hibernate supports multiple transaction types.
Explanation: update() modifies existing records.
Explanation: get() retrieves object immediately.
Explanation: load() uses proxy, get() fetches data immediately.
Explanation: Eager loading fetches data immediately.
Explanation: Lazy loading fetches data when needed.
Explanation: FetchType controls fetch strategy.
Explanation: Transient objects are not associated with Session.
Explanation: Persistent objects are linked to Session.
Explanation: Detached objects were persistent earlier.
Explanation: evict() removes object from cache.
Explanation: flush() synchronizes changes.
Explanation: Hibernate internally uses JDBC.
Explanation: Hibernate integrates with multiple frameworks.
Explanation: FROM Entity is valid HQL.
Explanation: All listed features improve performance.
Explanation: Transaction manages commit and rollback.
Explanation: delete() removes data permanently.
Explanation: ORM reduces need to write SQL.
Explanation: @ManyToMany maps many-to-many relationship.
Explanation: XML mapping file is optional with annotations.
Explanation: Dialect handles DB-specific SQL.
Explanation: SessionFactory is heavy-weight.
Explanation: Hibernate maps Java objects to databases.
This beginner-level Hibernate quiz is designed for learners starting with ORM and Java persistence. It covers Hibernate fundamentals such as ORM concepts, configuration, mappings, annotations, Session, SessionFactory, CRUD operations, and basic interview questions.