Complete the code to declare a JPA entity class with the correct annotation.
import jakarta.persistence.[1]; @[1] public class User { private Long id; private String name; }
The @Entity annotation marks the class as a JPA entity, which means it maps to a database table.
Complete the code to mark the primary key field with the correct annotation.
import jakarta.persistence.Entity; import jakarta.persistence.[1]; @Entity public class Product { @[1] private Long id; private String name; }
The @Id annotation marks the field as the primary key of the entity.
Fix the error in the code by choosing the correct annotation to generate the primary key value automatically.
import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.[1]; @Entity public class Order { @Id @[1] private Long id; private String product; }
The @GeneratedValue annotation tells JPA to generate the primary key value automatically.
Fill both blanks to complete the JPA entity with a primary key and a column annotation.
import jakarta.persistence.Id; import jakarta.persistence.[1]; import jakarta.persistence.[2]; @[1] public class Customer { @Id private Long id; @[2](name = "customer_name") private String name; }
@Entity marks the class as a JPA entity. @Column customizes the mapping of the field to the database column.
Fill all three blanks to complete the JPA entity with @Entity, @Id, and @GeneratedValue annotations.
import jakarta.persistence.[1]; import jakarta.persistence.[2]; import jakarta.persistence.[3]; @[1] public class Invoice { @[2] @[3] private Long id; private Double amount; }
@Entity marks the class as a JPA entity. @Id marks the primary key field. @GeneratedValue tells JPA to generate the key automatically.