Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Question from Enthuware

 
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?
 
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!