Senior Java Software Developer Interview Questions — part 2
4 min readFeb 26, 2023
1. Describe Proxy Design Pattern. Where we can find already implemented Proxy Design Pattern in Spring?
- The Proxy design pattern is a structural pattern that allows for the creation of a placeholder or surrogate object that can act as a substitute for a real object. The proxy provides a layer of indirection between the client and the real object, which allows the proxy to perform additional operations before or after forwarding requests to the real object.
- When a method annotated with
@Transactional
is called, Spring dynamically creates a proxy object around the actual object that is being invoked. This proxy intercepts the method call and starts a transaction before the actual method is executed. Once the method completes, the proxy commits the transaction, or rolls it back if an exception occurs.
2. Describe caching levels in hibernate.
- First-level cache: Also known as session cache, it is a temporary cache that exists for the duration of a Hibernate session. This cache stores objects that have been retrieved from the database during the current session, and subsequent requests for the same object are served from this…