Spring Data & JPA Flashcards
7 cards from real Spring Framework practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 7 Spring Data & JPA flashcards as text
Which annotation marks a Java class as a JPA entity that can be persisted in a relational database?
Answer: @Entity
@Entity designates a Java class as a JPA entity, mapping it to a database table for persistence.
Which Spring Data interface provides the minimum set of CRUD operations for a repository?
Answer: CrudRepository
CrudRepository defines the core CRUD methods (save, findById, findAll, delete, count) that all Spring Data repositories can extend.
What does the @GeneratedValue annotation configure when used alongside @Id in a JPA entity?
Answer: The strategy used to generate primary key values
@GeneratedValue specifies the strategy (AUTO, IDENTITY, SEQUENCE, TABLE) used to automatically generate primary key values.
Which annotation is used in a Spring Data JPA repository interface to define a custom JPQL or native SQL query?
Answer: @Query
@Query allows you to define a custom JPQL or native SQL query directly on a repository method using its value or nativeQuery attributes.
What is the primary effect of applying @Transactional to a Spring service method?
Answer: The method executes within a database transaction, with automatic commit or rollback
@Transactional wraps the method in a database transaction, automatically committing on success or rolling back on exception.
How does saveAndFlush() in JpaRepository differ from save()?
Answer: It immediately synchronizes the entity state with the database within the current transaction
saveAndFlush() calls save() and then immediately flushes the persistence context, pushing changes to the database within the current transaction.
What is the return type of the findById() method defined in Spring Data's CrudRepository?
Answer: Optional
findById() returns Optional to safely handle the case where no entity with the given ID exists, avoiding NullPointerExceptions.
How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. Exam facts are checked against the official sources listed below. Not reviewed by a subject-matter expert. Editorial policy
Sources & references
Exam facts on this page (fees, format, dates, passing scores) are checked against these official sources; the date is our last check. Editorial policy
- docs.broadcom.com — Test delivery, retake policy, exam information · verified Oct 2026
- spring-academy.broadcom.com — Eligibility · verified Oct 2026
- broadcom.com — Fees, exam format, passing score, time limit · verified Oct 2026