Spring & Hibernate Interview Questions: What Really Happens Under the Hood? After my previous blog on Java & Spring internals , one thing became pretty clear: Knowing the annotation is easy. Explaining what happens because of that annotation is where the real interview begins. You can write: @Transactional But do you know how Spring actually starts the transaction? You can add a Spring Boot dependency. But do you know why Spring suddenly creates a bunch of beans? You can modify a JPA entity without explicitly calling save() . But do you know why Hibernate still sends an UPDATE query? And here's the one I really like: Two users try to buy the last item in stock at exactly the same time. What happens? These are the kinds of questions that move an interview from "Do you know Spring?" to "Do you actually understand Spring?" So, let's go under the hood again. 🔹 Spring & Spring Boot 1. @Bean vs @Component — What's Actually Different? At firs...
Java & Spring Interview Questions: What Really Happens Under the Hood There is a phase in every developer's career where you can use something without actually understanding what is happening underneath. You know how to use ConcurrentHashMap . You know what @Transactional does. You know that Spring injects dependencies. You know @SpringBootApplication starts your application. And then the interviewer asks: "Okay, but what actually happens internally?" Suddenly, knowing the syntax isn't enough. That is exactly what this blog is about. I'm going to break down some of the Java and Spring concepts that are frequently asked in interviews, but more importantly, I'll try to understand why they work the way they do . Let's start with one of my favourites. 1. ConcurrentHashMap in Java 8: What Actually Happens? Let's first establish the problem. A normal HashMap is not thread-safe. Imagine two threads doing this at the same time: map.put("A",...