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-ntMapping 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 codeCode:
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?