Hi all
i am having a problem with my many-to-many relationship.
when i am calling the save function in the dao. its saving everything eccept the many to many relationship.
In my FunctionType class i have this:
Code:
/**
* @hibernate.set table="FunctionType_competentionLevels_bridge" inverse="true" cascade="save-update" lazy="true"
* @hibernate.collection-key column="FunctionTypeId"
* @hibernate.collection-many-to-many class="nl.carthago_ict.eHRM.model.CompetentionLevel" column="CompetentionLevelId"
*
* @return Set of CompetentionLevels
*/
public Set getCompetentionLevels() {
return competentionLevels;
}
public void setCompetentionLevels(Set competentionLevels) {
this.competentionLevels = competentionLevels;
}
the XML file:
Code:
<set
name="competentionLevels"
table="FunctionType_competentionLevels_bridge"
lazy="true"
inverse="true"
cascade="save-update"
>
<!-- @hibernate.collection-key tag is deprecated, use @hibernate.key instead -->
<key
column="FunctionTypeId"
>
</key>
<!-- @hibernate.collection-many-to-many tag is deprecated, use @hibernate.many-to-many instead -->
<many-to-many
class="nl.carthago_ict.eHRM.model.CompetentionLevel"
column="CompetentionLevelId"
outer-join="auto"
/>
</set>
and this is what i have in the action:
Code:
Set competentionLevels = new HashSet();
// .. filling the set like below
// ... competentionLevels.add(competentionLevelManager.getCompetentionLevel(parameter));
// ... now there are 5 elements in the set.
functionType.setCompetentionLevels(competentionLevels);
functionType.setName(functionType.getName()+"H");
log.debug(">>> saveCompetentionLevels2Size " +functionType.getCompetentionLevels().size());
functionTypeManager.saveFunctionType(functionType);
log.debug(">>> saveCompetentionLevels3Size " +functionType.getCompetentionLevels().size());
because of the logging... you can see that the size was first 2 (these where pun the the DB manualy) and after some competentionlevels added to the new set and replacing the old set with the new set its shows me "5" in the log. after saving its still "5"
but in the database nothing happend and the values have not beed added.. anyone ,.. plz??
PS: as you can see i am also changing the name... this change WILL be set... so there is no problem with the databse or anything (i guess)