• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

question about primary key in JPA

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
mock question:

Which statement is true about the primary key of a Java Persistence entity?
A. The primary key cannot be overridden by a mapping descriptor.
B. The location of the primary key defines in the topmost entity class in the hierarchy.
C. If property-based access is used, the properties or the primary key class must be public or protected.
D. At least part of a primary key must be defined in the class that is the topmost class of an entity which is defined by a hierarchy of classes.

Given answer is C,primary key could be put in mapped superclass too,so B is wrong,D apparently wrong.
why A is wrong?
can anyone explain C(why property-based,why public or protected,and how about field-based access?)
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason for C is tat when you using property based access, the accessor methods(getter/setter) should be public or protected. It cant b private or default.
 
when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic