-->
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.  [ 2 posts ] 
Author Message
 Post subject: many-to-many not storing the relationship
PostPosted: Sat Jun 17, 2006 3:49 pm 
Newbie

Joined: Sat Jun 17, 2006 3:10 pm
Posts: 7
Location: Canada
Hi,

I'm trying store a Vehicle with a newly created LicensePlate using a many-to-many relationship. Here is the mapping (simplified):

Code:
<class name="Vehicle"
      table="vehicle">
      <id name="id" column="id" type="long" unsaved-value="0">
         <generator class="sequence">
            <param name="sequence">vehicle_id_seq</param>
         </generator>
      </id>
      <bag name="licensePlates" table="license_plate_to_vehicle" lazy="true"
         cascade="all-delete-orphan" inverse="true">
         <key column="vehicle_id"/>
         <many-to-many  column="license_plate_id" class="LicensePlate" />
      </bag>
</class>

   <class name="LicensePlate"
      table="license_plate">
      <id name="id" column="id" type="long" unsaved-value="0">
         <generator class="sequence">
            <param name="sequence">license_plate_id_seq</param>
         </generator>
      </id>
      <property name="number" column="number" />
      <many-to-one name="locationOfRegistration" column="state_province_id"
             class="StateProvince" />
      <property name="isActive" column="is_active" />
   </class>


When I add a new LicensePlate to Vehicle and store, it is storing the LicensePlate (here's the debug sql):
Code:
insert into license_plate (number, state_province_id, is_active, id) values (?, ?, ?, ?)

But, it is NOT storing the license_plate_to_vehicle relationship. I know this is a simple many-to-many and I'm not sure I'm missing something obvious. Can you see what? Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 18, 2006 9:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You have inverse=true on the one and only side of the many-to-many declaration. Make it inverse false.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.