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