This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
When the value type of the map is an entity, a join table is used to map the map for a many-to-many relationship or, by default, for a one-to-many unidirectional relationship. If the relationship is a bidirectional one-to-many/many-to-one relationship, by default the map is mapped in the table of the entity that is the value of the map.
I've read this on the Enthuware Test Studio, 1st exam, as the explanation of the question:
You are modeling a relationship between Customer and CreditCard entities where a Customer can have many CreditCards but a CreditCard belongs to only one Customer. Further, you allow the users to associate a name with each credit card that they have. You have decided to use a Map to store the credit cards in Customer entity, where the key is the name and value is CreditCard entity.
Which of the following options correctly defines creditCards field in Customer class?
My doubt is, what the explanation meant with:
If the relationship is a bidirectional one-to-many/many-to-one relationship, by default the map is mapped in the table of the entity that is the value of the map.
This "element collection and mapping relationships to collection types such as Map's" subject is extremely confusing and boring and neither in the Pro Master JPA 2 nor in the simulates are well explained, I'll read this section of the specification and try to really understand it, but until now it's hard.
Feel free to ask me anything!
www.BlackBeltFactory.com/ui#!/ref=jmotta, SCJP 6, OCWCD JEE5, OCE EJB JEE6