-->
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: Recursive many-to-many relationship no insert possible
PostPosted: Fri Nov 10, 2006 10:51 am 
Newbie

Joined: Fri Nov 10, 2006 10:34 am
Posts: 1
I have a problem with a recursive many-to-many relationship.
Whenever I try to add some values to my collections hibernate doesn't seem to generate inserts for the n:m table when I save the object to the database. In the hibernate output i see the following sql:

Code:
Hibernate: insert into USER (EMPL_TYPE, DEFAULT_PROJECT_TASK, EMAIL, PASSWORD, ACTIVE, FIRSTNAME, INITIALNAME, LASTNAME, TITLE, USERLEVEL, USERNAME, PARENT_ID, CREATE_DATE, CREATE_USER, CHANGE_DATE, CHANGE_USER, leaderProfitCenter, ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

But this is just the insert for my user object, there is no insert for the many-to-many table. I will attach some information that might be helpful:

Hibernate version: 2.1.8
Name and version of the database you are using: MySQL 4.1.19-community-nt
Mapping documents :
Code:
<set name="profitCenterMember" table="PROFITCENTERMEMBER" lazy="true" inverse="true" cascade="save-update" sort="unsorted">
  <key column="LEADER_ID"> </key>
  <many-to-many class="com.myproject.pojos.User" column="EMPLOYEE_ID" outer-join="auto"/>
</set>

<set name="profitCenterLeader" table="PROFITCENTERMEMBER" lazy="false" inverse="false" cascade="delete" sort="unsorted">
  <key column="EMPLOYEE_ID"></key>
  <many-to-many class="com.myproject.pojos.User" column="LEADER_ID" outer-join="auto"/>
</set>


Database DDL code

Code:
create table USER (
   ID bigint not null,
   EMPL_TYPE bigint,
   DEFAULT_PROJECT_TASK bigint,
   DIVISION_ID bigint,
   EMAIL varchar(80) not null,
   PASSWORD varchar(50) not null,
   ACTIVE bit not null,
   FIRSTNAME varchar(50) not null,
   INITIALNAME varchar(5),
   LASTNAME varchar(50) not null,
   TITLE varchar(20),
   USERLEVEL integer not null,
   USERNAME varchar(30) not null,
   temporaryTimeSlice bigint,
   PARENT_ID bigint,
   CREATE_DATE datetime,
   CREATE_USER bigint not null,
   CHANGE_DATE datetime not null,
   CHANGE_USER bigint not null,
   leaderProfitCenter bit,
   primary key (ID)
);
create table PROFITCENTERMEMBER (
   LEADER_ID bigint not null,
   EMPLOYEE_ID bigint not null,
   primary key (EMPLOYEE_ID, LEADER_ID)
);


Does anyone know why this doesn't work?


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.