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

Moderator: admin

Post Reply
himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

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

Post by himaiMinh »

For option 3, does it mean it is not legal to use Address as the map key for CustOrder ?
Example:

Code: Select all

@Embeddable
public class Address{

   ...
   @OneToOne
     Customer customer;
}

Code: Select all

@Entity
public class CustOrder{


//Address contained the one-to-one relationship for some other entities, so Address cannot be used as a map key here ?
@ElementCollection
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.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

That is correct.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 43 guests