Spring Boot

JPA Entities & Relationships

JPA entities with @Entity, @Id, relationships (@OneToMany, @ManyToOne, @ManyToMany), @JoinColumn, cascade

30 câu hỏi phỏng vấn·
Mid-Level
1

Which annotation marks a class as a JPA entity?

Câu trả lời

@Entity is the mandatory annotation to declare a class as a JPA entity that will be mapped to a database table. Without this annotation, the EntityManager cannot manage the object's lifecycle. Each entity must also have a unique identifier annotated with @Id to be valid.

2

Which annotation defines the primary key of a JPA entity?

Câu trả lời

@Id identifies the field that will serve as the primary key for the entity. This annotation is mandatory on at least one field of each entity. The primary key guarantees the uniqueness of each record and allows JPA to properly manage merge, refresh, and remove operations.

3

Which annotation customizes a column name in the database?

Câu trả lời

@Column allows customizing the mapping between a Java field and a database column, particularly to define the column name, its length, whether it accepts null values, or if it is unique. Without this annotation, JPA uses the Java field name as the default column name.

4

How to specify a table name different from the class name?

5

Which @GeneratedValue strategy uses a database sequence?

+27 câu hỏi phỏng vấn

Nắm vững Spring Boot cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí