Hibernate Framework Cheat Sheet 2026

The 30 highest-yield Hibernate Framework facts, distilled from real exam questions. Print it, save it as a PDF, or study it here — free, no sign-up.

  1. Which of the following statements about ORM vs. JDBC is correct? All of these
  2. Which annotation prevents a field from being persisted in Hibernate? @Transient
  3. What is a collection cache in Hibernate? A cache region for caching entity collection associations separately
  4. Which fetch profile feature allows overriding fetch strategies at runtime in Hibernate? @FetchProfile and session.enableFetchProfile()
  5. Which Hibernate statistic tells you the second-level cache hit ratio? Statistics.getSecondLevelCacheHitCount() / (hit + miss)
  6. Which method evicts all entities of a given class from the second-level cache? sessionFactory.getCache().evictEntityData(EntityClass.class)
  7. What does the 'hibernate.order_inserts=true' property do? Groups INSERT statements by entity type to improve JDBC batch efficiency
  8. What does the hibernate.format_sql property do? Formats SQL output with line breaks for readability
  9. What is the role of transaction.rollback() in Hibernate? Undoes all changes made since the transaction began
  10. Which HQL clause is used to filter results, equivalent to SQL WHERE? WHERE
  11. What does setting hibernate.show_sql=true do? Logs all generated SQL statements to the console
  12. What does the @Table annotation do in Hibernate? Specifies the database table name for an entity
  13. Which method executes an HQL SELECT query that returns a list of results? query.list()
  14. In a bidirectional one-to-many relationship, which side is considered the 'owning side'? The 'many' side (child entity) with the foreign key
  15. What does HQL stand for in Hibernate? Hibernate Query Language
  16. Which annotation creates a join table for a many-to-many relationship? @JoinTable
  17. What is cache stampede (dog-pile effect) in the context of Hibernate caching? Multiple threads simultaneously regenerate an expired cache entry
  18. What is the difference between session.save() and session.persist() in Hibernate? save() returns the generated ID immediately; persist() is JPA-standard and returns void
  19. What is the purpose of the persistence.xml file in JPA/Hibernate? Defines a persistence unit with provider, data source, and entity classes
  20. Which method adds a WHERE condition to a CriteriaQuery? criteriaQuery.where(predicate)
  21. Which annotation is used to mark a class as a JPA entity in Hibernate? @Entity
  22. How do you enable the query cache for a specific Hibernate query? query.setCacheable(true)
  23. What does the @Transactional annotation do in Spring+Hibernate? Wraps the method in a database transaction automatically
  24. What does the 'mappedBy' attribute in @OneToMany indicate? The field in the owning entity that maps the relationship
  25. Which of the following statements about JDBC is correct? All of the above
  26. What does session.evict(entity) do in Hibernate? Removes the entity from the first-level cache without deleting from the database
  27. What is the purpose of the hibernate.dialect property? Specifies the SQL dialect for the target database
  28. How do you begin a transaction in Hibernate using the Session API? session.beginTransaction()
  29. Which Hibernate feature helps identify slow queries and performance bottlenecks? Hibernate Statistics API (session.getSessionFactory().getStatistics())
  30. Which CascadeType causes a delete operation on a parent entity to propagate to its child entities? CascadeType.REMOVE