08 November 2020

#Hibernate

#Hibernate

Key Concepts


Level Topic Subtopics
Basic Introduction What is Hibernate, Features of Hibernate, ORM Concepts, Hibernate Architecture, Advantages of Hibernate
Setup & Configuration Installing Hibernate, Hibernate Dependencies, Hibernate Configuration Files, Hibernate Properties, Annotation vs XML configuration
Basic CRUD Operations Session, Transaction, Save(), Persist(), Update(), Delete(), Get(), Load(), SessionFactory
Hibernate Data Types Primitive Types, Wrapper Types, Date & Time Types, Collections, Custom Types
Hibernate Mappings Mapping Classes to Tables, Mapping Attributes to Columns, @Entity, @Table, @Column, @Id
Intermediate Associations & Relationships One-to-One, One-to-Many, Many-to-One, Many-to-Many, Mapping Annotations, Cascade Types, Fetch Types, JoinTable, JoinColumn
Hibernate Query Language (HQL) Introduction to HQL, HQL Syntax, HQL Select Queries, HQL Update/Delete, Named Queries, Aggregate Functions
Criteria API Creating Criteria, Restrictions, Projections, Logical Expressions, Ordering, Pagination
Hibernate Caching First-Level Cache, Second-Level Cache, Query Cache, Cache Providers, Cache Annotations
Inheritance Mapping Single Table Strategy, Joined Table Strategy, Table per Class Strategy, @Inheritance, @DiscriminatorColumn
Advanced Transactions & Concurrency ACID Concepts, Transaction Management, Optimistic Locking, Pessimistic Locking, Versioning, @Version Annotation
Fetching Strategies Eager vs Lazy Loading, N+1 Problem, Batch Fetching, FetchMode, @Fetch Annotation
Hibernate Events & Listeners Event Types, PreInsert, PostInsert, PreUpdate, PostUpdate, PreDelete, PostDelete, Event Listeners
Hibernate Interceptors Implementing Interceptors, onSave(), onDelete(), onLoad(), Custom Interceptors
Advanced HQL & Native Queries HQL Joins, Subqueries, Group By, Having, Named Native Queries, SQLQuery API
Expert Performance Tuning Optimizing Session Usage, Batch Processing, Lazy Loading Best Practices, Fetch Joins, Indexing, Query Optimization
Hibernate Search Integrating Hibernate Search, Lucene, Full-Text Search, Indexing Entities, Querying Index
Multi-Tenancy Database Multi-Tenancy, Schema Multi-Tenancy, Discriminator Multi-Tenancy, Configuration
Advanced Caching Techniques Custom Cache Regions, Cache Concurrency Strategies, Read-Only, Non-Strict Read-Write, Transactional Cache
Best Practices & Design Patterns Session Management, DAO Pattern, Repository Pattern, Open Session In View Pattern, Avoiding Common Pitfalls

Interview question

1. Hibernate Basics

  1. What is Hibernate and why is it used?
  2. Explain ORM (Object-Relational Mapping) concept.
  3. What are the main features of Hibernate?
  4. Difference between Hibernate and JDBC.
  5. Explain Hibernate architecture.
  6. What is SessionFactory in Hibernate?
  7. What is a Session in Hibernate?
  8. Difference between get() and load() methods.
  9. Explain Hibernate Query Language (HQL).
  10. What are Hibernate annotations?
  11. Difference between Hibernate XML configuration and annotation-based configuration.
  12. Explain Hibernate?s advantages over JDBC.
  13. What are persistent, detached, and transient objects?
  14. Explain Hibernate?s first-level cache.
  15. How do you configure Hibernate using hibernate.cfg.xml?
  16. What is Hibernate mapping?
  17. Difference between @Entity and @Table annotations.
  18. Explain @Id and @GeneratedValue annotations.
  19. How do you save an object using Hibernate?
  20. How do you update an object using Hibernate?
  21. How do you delete an object using Hibernate?
  22. Difference between persist() and save() methods.
  23. Difference between merge() and update() methods.
  24. How do you handle exceptions in Hibernate?
  25. Explain Hibernate?s lifecycle of an entity.

2. Hibernate Mappings & Relationships

  1. Explain One-to-One mapping in Hibernate.
  2. Explain One-to-Many mapping in Hibernate.
  3. Explain Many-to-One mapping in Hibernate.
  4. Explain Many-to-Many mapping in Hibernate.
  5. Difference between unidirectional and bidirectional mapping.
  6. How do you map collections in Hibernate?
  7. Explain @JoinColumn annotation.
  8. Explain @JoinTable annotation.
  9. How do you handle composite keys in Hibernate?
  10. What is @EmbeddedId and @Embeddable?
  11. Difference between @ElementCollection and @CollectionTable.
  12. How do you map inheritance in Hibernate?
  13. Explain single-table inheritance strategy.
  14. Explain joined-table inheritance strategy.
  15. Explain table-per-class inheritance strategy.
  16. What is @DiscriminatorColumn and @DiscriminatorValue?
  17. Difference between eager and lazy fetching.
  18. Explain @OneToMany(fetch=FetchType.LAZY).
  19. Explain cascade types in Hibernate.
  20. How do you implement orphan removal?
  21. Difference between mappedBy and owning side in relationships.
  22. How do you map a bidirectional Many-to-Many relationship?
  23. How do you handle self-referencing associations?
  24. How do you handle join fetch to avoid N+1 problem?
  25. Best practices for Hibernate mappings.

3. Hibernate Queries

  1. What is HQL and how is it different from SQL?
  2. How do you write basic HQL queries?
  3. How do you write HQL update queries?
  4. How do you write HQL delete queries?
  5. Explain named queries in Hibernate.
  6. Difference between named query and native query.
  7. How do you pass parameters in HQL?
  8. How do you use positional and named parameters?
  9. Explain criteria API in Hibernate.
  10. Difference between criteria and HQL.
  11. How do you add restrictions in criteria queries?
  12. How do you use projections in criteria queries?
  13. How do you implement pagination in HQL and criteria queries?
  14. Explain aggregate functions in HQL.
  15. How do you perform joins in HQL?
  16. How do you implement subqueries in HQL?
  17. How do you use group by and having in HQL?
  18. Difference between fetch join and normal join.
  19. How do you execute native SQL queries in Hibernate?
  20. Difference between executeUpdate() and getResultList().
  21. How do you map query results to DTOs?
  22. How do you handle dynamic queries in Hibernate?
  23. What is query caching in Hibernate?
  24. How do you optimize HQL queries?
  25. Best practices for Hibernate queries.

4. Hibernate Transactions & Concurrency

  1. What is a transaction in Hibernate?
  2. How do you begin and commit a transaction?
  3. Difference between transaction and session in Hibernate.
  4. How do you handle rollback in Hibernate?
  5. Explain ACID properties in the context of Hibernate.
  6. Difference between optimistic and pessimistic locking.
  7. How do you implement versioning in Hibernate?
  8. Explain @Version annotation.
  9. How do you handle concurrent updates in Hibernate?
  10. Difference between optimistic and pessimistic concurrency control.
  11. How do you use LockMode in Hibernate?
  12. Difference between transaction-scoped and session-scoped transactions.
  13. How do you integrate Hibernate with JTA?
  14. Difference between programmatic and declarative transactions.
  15. How do you handle nested transactions in Hibernate?
  16. How do you use Spring transaction management with Hibernate?
  17. Difference between read-only and read-write transactions.
  18. How do you handle long-running transactions?
  19. How do you implement rollback rules in Spring + Hibernate?
  20. How do you manage isolation levels in Hibernate?
  21. Difference between transaction propagation behaviors.
  22. How do you test transaction behavior in Hibernate?
  23. How do you prevent lost updates in Hibernate?
  24. How do you handle deadlocks in Hibernate transactions?
  25. Best practices for transaction management.

5. Hibernate Caching

  1. What is caching in Hibernate?
  2. Difference between first-level cache and second-level cache.
  3. Explain session cache in Hibernate.
  4. How do you enable second-level cache?
  5. What are cache providers in Hibernate?
  6. Explain query cache in Hibernate.
  7. Difference between query cache and second-level cache.
  8. How do you configure cache concurrency strategies?
  9. What is read-only cache strategy?
  10. What is read-write cache strategy?
  11. Explain non-strict read-write cache.
  12. Difference between transactional cache and non-transactional cache.
  13. How do you evict cache entries manually?
  14. How do you clear session cache?
  15. How do you use @Cache annotation?
  16. How do you integrate EHCache with Hibernate?
  17. How do you integrate Infinispan with Hibernate?
  18. How do you handle cache invalidation?
  19. How do you monitor cache performance?
  20. How do you optimize caching in Hibernate?
  21. Difference between collection caching and entity caching.
  22. How do you use natural IDs with caching?
  23. How do you enable caching for read-only entities?
  24. How do you configure cache regions?
  25. Best practices for Hibernate caching.

6. Hibernate Events & Interceptors

  1. What are Hibernate events?
  2. Difference between events and interceptors.
  3. What are pre-insert and post-insert events?
  4. What are pre-update and post-update events?
  5. What are pre-delete and post-delete events?
  6. How do you implement event listeners in Hibernate?
  7. How do you register event listeners?
  8. Explain lifecycle callbacks in Hibernate.
  9. What is Hibernate Interceptor?
  10. How do you implement onSave() in an interceptor?
  11. How do you implement onDelete() in an interceptor?
  12. How do you implement onLoad() in an interceptor?
  13. How do you implement onFlushDirty() in an interceptor?
  14. Difference between session-scoped and global interceptors.
  15. How do interceptors affect performance?
  16. How do you use interceptors with JPA?
  17. How do you debug Hibernate events?
  18. Difference between pre-commit and post-commit events.
  19. How do you prevent unwanted event execution?
  20. How do you chain multiple interceptors?
  21. Difference between EntityListeners and Hibernate events.
  22. How do you implement auditing using events?
  23. How do you implement logging using interceptors?
  24. How do you test events and interceptors?
  25. Best practices for Hibernate events and interceptors.

7. Advanced Hibernate Concepts

  1. How do you implement batch processing in Hibernate?
  2. What is StatelessSession in Hibernate?
  3. Difference between Session and StatelessSession.
  4. How do you handle large data sets efficiently?
  5. What is multi-tenancy in Hibernate?
  6. Explain database multi-tenancy strategy.
  7. Explain schema multi-tenancy strategy.
  8. Explain discriminator multi-tenancy strategy.
  9. How do you implement auditing in Hibernate?
  10. How do you integrate Hibernate Envers?
  11. How do you handle soft deletes?
  12. How do you implement full-text search with Hibernate Search?
  13. How do you integrate Hibernate Search with Lucene?
  14. How do you implement projections and aggregations?
  15. How do you use Criteria API for complex queries?
  16. How do you handle native SQL queries?
  17. Difference between SQLQuery and NativeQuery.
  18. How do you map complex results to DTOs?
  19. How do you handle dynamic entity models?
  20. How do you optimize Hibernate performance?
  21. How do you monitor Hibernate SQL queries?
  22. How do you use logging frameworks with Hibernate?
  23. How do you implement custom types in Hibernate?
  24. How do you implement secondary tables for entities?
  25. Best practices for advanced Hibernate concepts.

Related Topics