Spring Data JPA Interview Questions and Answers

Spring Data JPA is one of the most popular starters used in Spring-based applications. If we look at GitHub statistics, we'll see that developers use Spring Data JPA in more than 900K projects. Compare it with 165K for Spring JDBC, and it becomes obvious that in many tech interviews developers face questions on Spring Data JPA and related technologies.   

In this article, we will take a look at the most popular Spring Data JPA interview questions. Also, we'll discuss underlying technologies – JPA and Hibernate. First, there will be some basic questions on general knowledge, and then we'll review advanced topics.  

Inheritance vs. Composition in JPA

Introduction

«Don't repeat yourself» or «DRY». Developers try to adhere to this principle during software development. It helps to avoid redundant code writing and, as a result, simplifies its maintainability in the future. But how to achieve this principle in the JPA world?

There are two approaches: Inheritance and Composition. Both have their pros and cons. Let's figure out what they are on the not quite "real-world" but representative example.