Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question from Enthuware

 
nitin pai
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Which of the following statements are correct regarding a class hierarchy of Entity classes?
1. An entity class must not extend from a Non-entity superclass.
2. A non-entity class must not extend an entity class.
3. There can be only one @MappedSuperclass class in a hierarchy and it must be the root class of the hierarchy.
4. The primary key must be defined on the entity that is the root of the entity hierarchy or on a mapped superclass of the entity hierarchy.
5. The primary key must be defined exactly once in an entity hierarchy.

The correct answers are: 4, 5


How can the option 5 be correct. Can't we can have an abstract entity with the primary key and also define it in its subclass by using @AttributeOverride?
 
E Lievaart
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you're thinking too deep about the question.
Indeed the behavior you describe is possible (according to spec).

When you'd use @AttributeOverride, you wouldn't add a pk.
Rather you will be modifying the definition of the pk.
So in this sense you are not defining a pk, but are modifying the definition.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic