-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Many-to-many update doest work
PostPosted: Wed Jul 04, 2007 5:01 pm 
Newbie

Joined: Tue Apr 24, 2007 2:43 am
Posts: 6
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)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.