StudyGPT Just Leveled Up – Say Hello to Knowee! 🚀
Knowee
Questions
Features
Study Tools

Which annotation is used to specify a primary key in Hibernate?@PrimaryKey@Id@Column@Entity

Question

🧐 Not the exact question you are looking for?Go ask a question

Solution

The annotation used to specify a primary key in Hibernate is @Id. This annotation marks a field in an entity class as the primary key that uniquely identifies each record in the database table.

Explanation of Choices

  1. @PrimaryKey: This is not a standard annotation in Hibernate.
  2. @Id: Correct choice for defining a primary key.
  3. @Column: Used to specify a column in the database table but does not denote the primary key.
  4. @Entity: Indicates that the class is an entity and is mapped to a database table but does not specify the primary key.

Final Answer

The correct annotation is @Id.

This problem has been solved

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.