This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML 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

My exam cloud mock 3, about untyped maps

 
Ranch Hand
Posts: 1742
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Given that there is unidirectional oneToMany relationship between a Customer and Order, you want to model
it as a Map in Customer as following:
Order has a property named paymentType of enum PaymentType, with values such as CREDITCARD, DEBITCARD....

You want the paymentType field of Order entity to be the key of the map and the Order entity to be the value. The
primary key of Order is orderId, which is an integer.
Which of the following options correctly specify this relationship?
Choose two.

A. @OneToMany
  @MapKey(name="paymentType")
  private Map<PaymentType, Order> orders;

B.@OneToMany
 @MapKeyEnumerated(PaymentType.class)
  private Map orders;

C. @OneToMay
  @MapKey(name="paymentType")
  private Map order;

Given answer A, B



I think the answer is only A.
B is not correct because it should be:
@OneToMany(targetEntity=Order.class)
@MapKeyEnumerated(PaymentType.class)
private Map orders;

 
Creator of Enthuware JWS+ V6
Posts: 3289
296
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agree, B is not correct.

I think for B you also need a @MapKeyClass annotation (note that the @MapKeyClass and @MapKey annotations cannot be used together)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!