Which of the following statements are correct w.r.t. entity bean?

  1. Every entity must have a primary key

  2. It is not necessary to define primary key for an Entity

  3. @Primary annotation is used for denoting a simple primary key

  4. All the above


Correct Option: A
Explanation:

To solve this question, the user needs to understand the basics of entity beans and their primary keys.

A) Every entity must have a primary key. This statement is true as the primary key is used to uniquely identify each entity bean in the database. Without a primary key, it would be impossible to distinguish between different instances of the same entity.

B) It is not necessary to define a primary key for an Entity. This statement is false. As mentioned above, every entity must have a primary key. It is not optional.

C) @Primary annotation is used for denoting a simple primary key. This statement is false. @Primary annotation is not a built-in annotation in Java Persistence API (JPA). Instead, the @Id annotation is used to denote a primary key.

D) Option B is incorrect. Therefore, the correct answer is:

The Answer is: A

Find more quizzes: