• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

My exam cloud mock 3, about untyped maps

 
Ranch Foreman
Posts: 1897
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: 3341
303
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)
 
This looks like a job for .... legal tender! It says so right in this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic