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
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
@PrimaryKey
: This is not a standard annotation in Hibernate.@Id
: Correct choice for defining a primary key.@Column
: Used to specify a column in the database table but does not denote the primary key.@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.
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
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.