-->
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.  [ 4 posts ] 
Author Message
 Post subject: many-to-many relations
PostPosted: Mon Dec 20, 2004 6:16 am 
Newbie

Joined: Mon Dec 20, 2004 6:05 am
Posts: 3
Hibernate version:
2.1.7
Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
sybase
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Hi everyone

Here is my problem. I've got 2 classes, Univers & ReunionDUnivers, with a many-to-many relation between.
Univers get a Set of ReunionDUnivers & Univers get a Set of Univers.

The java code of ReunionDUnivers.java :
Code:
private Set univers;

  /**
   *
   * @return
   *
   * @hibernate.set
   *  cascade="all"
   *  inverse="true"
   *  table="MTM_UnivSple_ReunionDUniv"
   * @hibernate.collection-many-to-many
   *  class="com.iaf.frontalbv.om.UniversSimple"
   * @hibernate.collection-key
   *  column="reunionDUnivers"
   * @hibernate.cache
   *  usage="read-write"
   *
   */


The java code of UniversSimple.java :
Code:
private Set reunionDUnivers;

  /**
   *
   * @return
   *
   * @hibernate.set
   *  cascade="all"
   *  inverse="true"
   *  table="MTM_UnivSple_ReunionDUniv"
   * @hibernate.collection-many-to-many
   *  class="com.iaf.frontalbv.om.ReunionDUnivers"
   * @hibernate.collection-key
   *  column="univers"
   * @hibernate.cache
   *  usage="read-write"
   *
   */


The treatment code source :
Code:
Session session = Persistance.currentSession();
Transaction transaction = session.beginTransaction();
//...
//treatment and updating ReunionDUnivers object
//...
session.saveOrUpdate(omReunionDUnivers);
transaction.commit();


Everything seems good, but nothing is updated/inserted in my table.

Someone can help me?[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 21, 2004 7:02 am 
Newbie

Joined: Mon Dec 20, 2004 6:05 am
Posts: 3
up


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 21, 2004 2:48 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you have 2 inverse=true .... read about inverse, that's really important

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 22, 2004 5:37 am 
Newbie

Joined: Mon Dec 20, 2004 6:05 am
Posts: 3
you're right.
Ive changed this, and add a missing element.

In ReunionDUnivers :
Code:
  private Set univers;

  /**
   *
   * @return
   *
   *
   * @hibernate.set
   [b]*  inverse="true"[/b]
   *  cascade="all"
   *  table="MTM_UnivSple_ReunionDUniv"
   * @hibernate.collection-many-to-many
   *  class="com.iaf.frontalbv.om.UniversSimple"
   [b]*  column="univers"[/b]
   * @hibernate.collection-key
   *  column="reunionDUnivers"
   * @hibernate.cache
   *  usage="read-write"
   *
   */


In UniversSimple :
Code:
  /**
   *
   * @return
   *
   * @hibernate.set
[b]   *  inverse="false"[/b]
   *  table="MTM_UnivSple_ReunionDUniv"
   * @hibernate.collection-many-to-many
   *  class="com.iaf.frontalbv.om.ReunionDUnivers"
   [b]*  column="reunionDUnivers"[/b]
   * @hibernate.collection-key
   *  column="univers"
   * @hibernate.cache
   *  usage="read-write"
   *


Here is the hbm code :


But nothing happen. :-(
Code:
<joined-subclass
            name="com.iaf.frontalbv.om.ReunionDUnivers"
            dynamic-update="true"
            dynamic-insert="true"
        >
        <key
            column="super_oid"
        />

        <set
            name="univers"
            table="MTM_UnivSple_ReunionDUniv"
            lazy="true" access="field"
            inverse="true"
            cascade="all"
            sort="unsorted"
        >
            <cache
                usage="read-write"
             />

              <key
                  column="reunionDUnivers"
              />

              <many-to-many
                  class="com.iaf.frontalbv.om.UniversSimple"
                  column="univers"
                  outer-join="auto"
              />

        </set>

        </joined-subclass>
        <joined-subclass
            name="com.iaf.frontalbv.om.UniversSimple"
            dynamic-update="true"
            dynamic-insert="true"
        >
        <key
            column="super_oid"
        />

        <set
            name="reunionDUnivers"
            table="MTM_UnivSple_ReunionDUniv"
            lazy="true" access="field"
            inverse="false"
            cascade="none"
            sort="unsorted"
        >
            <cache
                usage="read-write"
             />

              <key
                  column="univers"
              />

              <many-to-many
                  class="com.iaf.frontalbv.om.ReunionDUnivers"
                  column="reunionDUnivers"
                  outer-join="auto"
              />

        </set>


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

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.