Knowee
Questions
Features
Study Tools

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

Question

Which annotation is used to specify a primary key in Hibernate?

@PrimaryKey @Id @Column @Entity

🧐 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

Similar Questions

What is the primary configuration file used by Hibernate?hibernate.propertieshibernate.cfg.xmlhibernate.xmlconfig.hibernate.xml

n a table, which of the following should be identified as the primary key? 1. field 2.  query 3. record 4. object

Which method in Hibernate is used to save an entity to the database?save()commit()persist()insert()

How does Hibernate achieve database independence?Using JDBCThrough dialect configurationBy using JPA annotationsNone of these

. What is a Primary key?*1 pointA. Foreign KeyB. Unique KeyC. Database keyD. format key

1/1

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.