Hello, I have a ManyToMany relationship between two tables: Xa_ Name (which represents a person) and WR_Engineering_Group
-------------------
Table.
Xa_Name
Xa_Name_Id (int, pk)
Full name (
String)
--------------------
---------------------
Table.
WR_Engineering_Group
Id (int, pk)
group_name (String)
-----------------------------
However, the joint table has an extra column to indicate if the person is an activate authority of the group as following:
-------------------
Table.
WR_Engineering_Group_Authority
Xa_Name_Id (int, pk) Reference Xa_Name.xa_name_Id
group(int, pk) Reference WR_Engineering_Group_Id
active(boolean, extra column)
--------------------
I use the following mapKeyClass method to join the two tables, and wish to use the attribute "active" to map the corresponding list of persons.
The GroupAuthorityStatus Class is just a embeddable class to wrap the extra column "active". The following is the implementation for this class
That is to say, given a group, I wish to map all the active authorities to a GroupAuthorityStatus that represents "True".
Now, it works fine to map the corresponding authorities and to add a new authority.
However, if I add a new active person as authority for a given group, the previously existing active person will be replaced by this new authority. Same problem occurs with adding a new inactive authority. It seems like only one person can be associated with the key(GroupAuthorityStatus). How could I change it to map a list of perons (List<XaName>) to the key(GroupAuthorityStatus).
The following is the method of activating a previously inactive authority. I remove the person first, and then add the person with true for its activity.
This works fine as long as there is only one person associated with the targeting status. If there already exists one person with the same status, the old person gets replaced by this incoming authority.
Any hint and help is greatly appreciated. Thank you very much for your time in advance.
By the way, I got the format of such mapkeyclass method from the following website:
google book for JPA2
MapKeyColumns from wiki