Spring Boot

JPA Entities & Relationships

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

30 pertanyaan wawancara·
Mid-Level
1

Which annotation marks a class as a JPA entity?

Jawaban

@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?

Jawaban

@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?

Jawaban

@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 pertanyaan wawancara

Kuasai Spring Boot untuk wawancara berikutnya

Akses semua pertanyaan, flashcards, tes teknis, latihan code review dan simulator wawancara.

Mulai gratis