advancedDI & IoC Internals98 of 469

Why can adding @Transactional change the actual object type returned by Spring?

Tests whether you know @Transactional triggers Spring to wrap the bean in a CGLIB subclass or JDK dynamic proxy, so getClass() on the injected reference no longer matches the original class -- which breaks naive instanceof or reflection-based code.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

← Back to all Spring Boot & Microservices questions