Page 1 of 1

About Question enthuware.oce-jpad.v6.1.437 :

Posted: Mon Jul 17, 2017 5:37 pm
by himaiMinh
For option 3, does it mean it is not legal to use Address as the map key for CustOrder ?

Code: Select all

public class Address{

     Customer customer;

Code: Select all

public class CustOrder{

//Address contained the one-to-one relationship for some other entities, so Address cannot be used as a map key here ?
Map<Address, Integer> balances;

Also from this statement :
An embeddable class may contain a relationship to an entity or collection of entities. Since instances of
embeddable classes themselves have no persistent identity, the relationship from the referenced entity is
to the entity that contains the embeddable instance(s) and not to the embeddable itself.[17] An
embeddable class that is used as an embedded id or as a map key must not contain such a relationship.
I guess the embeddable class that refers to a relationship between other two entities cannot be an embeddable id or a map key because there is a coupling in the embeddable class. For example, the embeddable Address is tightly coupled to the Customer entity and that is why it cannot be used as an Id or a map key.

Re: About Question enthuware.oce-jpad.v6.1.437 :

Posted: Tue Jul 18, 2017 2:33 am
by admin
That is correct.