All questions
of 38What is the difference between Hibernate and JDBC?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
| Aspect | JDBC | Hibernate |
|---|---|---|
| Code Complexity | More boilerplate code | Minimal code required |
| Database Dependency | Database-specific SQL | Database-independent HQL |
| Object Mapping | Manual conversion | Automatic ORM |
| Caching | No built-in caching | Multi-level caching |
| Performance | Faster for simple operations | Better for complex applications |
| Learning Curve | Easier to learn | Steeper learning curve |
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
What are the core interfaces of Hibernate?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
The core interfaces in Hibernate are:
- Configuration: Used to configure Hibernate and create SessionFactory
- SessionFactory: Factory for Session objects, thread-safe and expensive to create
- Session: Main interface for persistence operations, not thread-safe
- Transaction: Handles database transactions
- Query: Used to execute HQL and SQL queries
- Criteria: Used for programmatic query building (deprecated in favor of CriteriaBuilder)
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
What is a SessionFactory and how is it different from Session?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
SessionFactory:
- Factory class that creates Session objects
- Thread-safe and immutable
- Expensive to create, typically one per application
- Holds second-level cache data
- Configuration is read-only after creation
Session:
- Interface between Java application and Hibernate
- Not thread-safe
- Lightweight and inexpensive to create
- Represents a single unit of work
- Should be created and closed for each transaction
// SessionFactory - created once
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
// Session - created per transaction
Session session = sessionFactory.openSession();
// ... perform operations
session.close();
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
What are the different states of a Hibernate entity?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Hibernate entities can be in one of four states:
- Transient: New object not associated with any session or database
- Persistent: Object associated with a session and has database representation
- Detached: Object was persistent but session is closed
- Removed: Object marked for deletion
User user = new User(); // Transient state
session.save(user); // Persistent state
session.close(); // Detached state
session.delete(user); // Removed state
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
What is the difference between save(), persist(), and saveOrUpdate()?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
- save(): Saves the entity and returns the generated identifier. Can be called outside transaction.
- persist(): Saves the entity but doesn't return identifier. Must be called within transaction.
- saveOrUpdate(): Saves new entity or updates existing one based on identifier.
// save() - returns ID
Long id = (Long) session.save(user);
// persist() - no return value
session.persist(user);
// saveOrUpdate() - smart save/update
session.saveOrUpdate(user);
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
The interactive diagram is below the answer - jump to diagram ↓
This answer is explained by a shared concept diagram - open →
What are the ways to configure Hibernate?
What is the purpose of @Entity and @Table annotations?
Explain the difference between lazy and eager loading in Hibernate.
What is the N+1 problem and how can it be solved?
Explain Hibernate caching mechanism.
What are the different cascade types in Hibernate?
What is HQL and how is it different from SQL?
Explain the different inheritance mapping strategies in Hibernate.
What are the different association mappings in Hibernate?
What is the difference between merge() and update()?
What are Hibernate Interceptors and Event Listeners?
Explain the concept of dirty checking in Hibernate.
How would you optimize Hibernate performance for large datasets?
What is the difference between getCurrentSession() and openSession()?
Explain Hibernate's flush modes and when to use each.
How do you handle optimistic locking in Hibernate?
What are the different transaction isolation levels and their implications?
Explain Hibernate's connection pooling and configuration.
How do you implement custom Hibernate types?
What is the difference between Criteria API and Query by Example?
How do you handle database schema evolution with Hibernate?
Explain the concept of Hibernate Envers for auditing.
What are the best practices for Hibernate session management in web applications?
How do you implement bulk operations efficiently in Hibernate?
What is the difference between stateless and stateful sessions?
How do you handle composite primary keys in Hibernate?
Explain Hibernate's second-level cache providers and their characteristics.
What are Hibernate filters and how are they used?
How do you implement multi-tenancy in Hibernate?
What are the considerations for Hibernate in microservices architecture?
How do you troubleshoot and debug Hibernate performance issues?
What are the differences between JPA and Hibernate-specific features?
How do you implement custom Hibernate naming strategies?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
Hibernate cheatsheet
Hibernate Interview Cheat Sheet
- Summary01
- 1. Core Concepts02
- 2. Configuration03
- 3. Entity Mapping04
- 4. Relationships05
- 5. Fetch Types & Cascade06
- 6. Session Operations07
- 7. Object States08
- 8. Query Methods09
- 9. Named Queries10
- 10. Caching11
- 11. Transactions12
- + 6 more inside
33 of 38 Hibernate answers are gated.
Full answers, code samples, AI explanations - simpler, deeper, or as an interactive diagram. Cancel anytime.
- Full answers + code
- AI explain - simpler, deeper, or visualized
- 1,000 AI credits / month
- Cancel anytime
Change topic
Pick a different technology or stack. Your current topic stays put until you choose a new one.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsLAMP
Linux, Apache, MySQL, PHPRuby on Rails
Convention over ConfigurationJAM
JavaScript, APIs, and MarkupServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQFastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseWeb3 / Ethereum
Solidity, Ethereum, Hardhat, FoundryDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.