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

Moderator: admin

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

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

Post by himaiMinh » Sun Jun 25, 2017 6:32 pm

Hi, everyone,
In the explanation,
When the key or value is an entity, AssociationOverride is used.
I think AssociationOverride is used when the value is an entity. I don't think we will use associationoverride to override the key.
Here is what the spec says:
The AttributeOverride(s) and AssociationOverride(s) annotations are
used to override the mappings for a map value that is an embeddable class.

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

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

Post by admin » Tue Jun 27, 2017 10:12 pm

This quote is only talking about the case when the value is an embedded class. What if the key or the value is an entity?
If you like our products and services, please help us by posting your review here.

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

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

Post by himaiMinh » Mon Jul 03, 2017 1:15 pm

If the key is an entity, we use @MapKeyJoinColumn to indicate there is a column with the primary key of this entity.
If the value is an entity, we use the primary key of the entity in the join table.

__JJ__
Posts: 125
Joined: Thu Jul 05, 2018 6:44 pm
Contact:

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

Post by __JJ__ » Mon Sep 17, 2018 1:25 pm

himaiMinh wrote:
Mon Jul 03, 2017 1:15 pm
If the key is an entity, we use @MapKeyJoinColumn to indicate there is a column with the primary key of this entity.
If the key is an entity, we use @MapKeyJoinColumn to override the default name of the column in the db that will hold the FK back to the entity's PK.

Code: Select all

    @ElementCollection
    @CollectionTable(name = "EMP_ROLE")
    @MapKeyJoinColumn(name = "EMP_ID") <== override default FK column name; but not really necessary
    @Column(name = "ROLE")
    private Map<Employee, String> employeeRole;

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests