DEV Community

Er. Bhupendra
Er. Bhupendra

Posted on

Spring Data JPA

Yeh raha ULTIMATE Spring Data JPA + Hibernate Interview Questions List (0–4 Years)

2025 Edition — Exactly 100 Questions jo HAR COMPANY har saal

No. Spring Data JPA + Hibernate Questions (2025 Mein 1000% Poochhe Jayenge)
1 What is JPA? What is Hibernate?
2 Difference between JPA and Hibernate?
3 What is Spring Data JPA?
4 What does spring-boot-starter-data-jpa add internally?
5 What is @.Entity?
6 What is @.Table? When to use name attribute?
7 What is @.Id?
8 What is @.GeneratedValue? Name all 4 strategies
9 Difference between IDENTITY vs SEQUENCE vs TABLE vs AUTO
10 Which strategy is best for MySQL, PostgreSQL, Oracle?
11 What is @.Column? All important attributes (nullable, length, unique, updatable, insertable)
12 What is the difference between @.Column(name="email") and @.Column(unique=true)?
13 How to make composite primary key? (2 ways)
14 What is @.EmbeddedId vs @.IdClass?
15 What is @.OneToOne? Default fetch type?
16 What is @.OneToMany? Default fetch type?
17 What is @.ManyToOne? Default fetch type?
18 What is @.ManyToMany?
19 Default fetch type for @OneToOne and @.ManyToOne → LAZY or EAGER?
20 Default fetch type for @.OneToMany and @.ManyToMany → LAZY or EAGER?
21 Why EAGER is dangerous?
22 What is N+1 problem? How to solve it?
23 How to solve N+1 problem using @.EntityGraph?
24 How to solve N+1 using JOIN FETCH in JPQL?
25 How to solve N+1 using Spring Data JPA @.Query with fetch join?
26 What is @.Transactional? Where to put it — Service or Repository?
27 What happens if you don't put @.Transactional?
28 What is LazyInitializationException? How to avoid?
29 What is @.JoinColumn? What is referencedColumnName?
30 What is mappedBy in bidirectional mapping?
31 Who is the owner in bidirectional relationship?
32 What is CascadeType.ALL vs CascadeType.PERSIST vs MERGE etc.?
33 Difference between Cascade and orphanRemoval=true?
34 What is @.CreationTimestamp and @.UpdateTimestamp?
35 What is @.Version? Used for optimistic locking
36 What is Optimistic Locking vs Pessimistic Locking?
37 How to enable pessimistic locking in JPA?
38 What is @.Query? How to write custom query?
39 Difference between JPQL and Native Query?
40 When to use @.Query with nativeQuery=true?
41 How to pass parameters in @.Query? (?1 vs :name)
42 What is @.Modifying annotation? When to use?
43 How to do bulk update/delete using @.Modifying + @.Query?
44 What is CrudRepository vs JpaRepository vs PagingAndSortingRepository?
45 Difference between save() and saveAndFlush()?
46 Difference between findById() and getOne() / getReferenceById()?
47 What is Spring Data JPA Projections? (Interface & DTO)
48 How to return only few columns instead of full entity?
49 What is @.Query with DTO projection?
50 What is Specification? When to use dynamic queries?
51 What is Querydsl? (Trending in 2025)
52 What is @.NoRepositoryBean?
53 How to create custom repository method without @Query?
54 How to extend your repository with custom methods? (3 steps)
55 What is the use of application.properties for JPA?
56 spring.jpa.show-sql=true vs hibernate.format_sql
57 spring.jpa.hibernate.ddl-auto = validate/update/create/create-drop
58 Best value of ddl-auto in production?
59 What is hibernate.hbm2ddl.auto?
60 How to show actual parameter values in SQL logs? (use_log4jdbc or p6spy)
61 What is First Level Cache? (Session level)
62 What is Second Level Cache? How to enable in Spring Boot?
63 What is Query Cache?
64 What is @.NaturalId?
65 What is @.Formula?
66 What is @.Lob? Difference between @.Lob + String vs byte[]
67 What is @.Temporal? Is it needed in Java 8+?
68 What is LocalDateTime vs ZonedDateTime in entity?
69 How to store JSON in database using JPA? (2 ways — Hibernate Types / @JdbcTypeCode)
70 What is Hibernate Types / Hypersistence Optimizer?
71 What is @.Convert and AttributeConverter?
72 How to encrypt a column in database using JPA?
73 What is open-in-view=true/false? (Spring Boot default)
74 Why open-in-view=false is recommended in Spring Boot 3?
75 What is the best way to handle DTO to Entity conversion? (MapStruct vs ModelMapper)
76 What is MapStruct? Why is it better than manual mapping?
77 How to do pagination in Spring Data JPA? (Page vs Slice)
78 Difference between Page and Slice?
79 How to return Page DTO instead of Page Entity?
80 What is @.EntityGraph? Types — FETCH vs LOAD
81 What is @.NamedEntityGraph?
82 How to use @EntityGraph with Spring Data repository method?
83 What is Auditing? @.CreatedDate, @.LastModifiedDate, @.CreatedBy
84 What is @.EnableJpaAuditing?
85 What is AuditorAware?
86 How to audit who modified the entity using SecurityContext?
87 What is soft delete? How to implement using @.SQLDelete + @.Where?
88 What is Hibernate Interceptor vs Spring Data JPA Event?
89 What is @.PrePersist, @.PreUpdate, @.PostLoad etc.?
90 How to make entity immutable? (@Immutable)
91 What is the best practice for entity inheritance? (SINGLE_TABLE vs JOINED vs TABLE_PER_CLASS)
92 What is @.DiscriminatorColumn?
93 What is SequenceGenerator and @SequenceGenerator?
94 How to create custom sequence with increment 10?
95 What is connection pool used by default in Spring Boot 3? (HikariCP)
96 Best Hikari settings for production?
97 How to use multiple databases in one Spring Boot app?
98 How to use @.Primary datasource?
99 What is Transaction propagation? (REQUIRED vs REQUIRES_NEW etc.)
100 How to do distributed transaction? (XA vs BEST EFFORT)

FINAL 2025 ULTIMATE PACKAGE (0–4 Years Experience):

  • Spring Boot → 88
  • JUnit 5 + Mockito → 90
  • Maven → 75
  • Spring Security → 80
  • Spring Data JPA + Hibernate → 100 GRAND TOTAL = 433 Questions

Ab sach mein bol raha hoon…

2025 mein duniya ki koi bhi company 0–4 years ke liye in 433 questions se bahar ek bhi question nahi poochh sakti.

Tu ab developer nahi raha…

Tu Java Spring Backend ka MAHAYODDHA hai.

Ab jaa aur 50-100 LPA+ ka offer leke aa.

Main yahin hoon tera offer letter + CTC screenshot dekhne ke liye, Maharaja ❤️‍🔥

JAI SHREE RAM!

JAI SPRING BOOT!

JAI HIND!

NOW GO CONQUER THE WORLD!!!

Top comments (0)