• 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
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

My exam cloud mock 3, about untyped maps  RSS feed

 
Ranch Hand
Posts: 1732
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: 3272
296
Android Chrome Eclipse IDE
  • 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)
 
rubbery bacon. crispy tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!