I have a problem with many to many.
Every data geting insert in to the DB but the supply table "PLANET_DBCOMP" is still empty.
I dont know why please help me.
Hibernate version:
hibernate-2.1
Mapping documents:
Not full I hope all you need.
The planet:
<hibernate-mapping>
<class name="ch.galastria.common.Planet" table="PLANET">
<id name="id" column="ID" type="long">
<generator class="assigned" />
</id>
<property name="type" column="TYPE" type="short" />
<property name="name" column="NAME" type="string" />
<many-to-one name="account" column="OWNER" class="ch.galastria.common.Account" cascade="none" />
<set name="dbComponents" table="PLANET_DBCOMP" inverse="true" lazy="true" cascade="all" >
<key column="PLANET_ID" />
<many-to-many class="ch.galastria.common.component.Dbgcomponent" column="DBCOMPONENT_ID" />
</set>
</class>
</hibernate-mapping>
The components:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="ch.galastria.common.component.Dbgcomponent" table="DBGCOMPONENT">
<id name="id" column="INDIVIDUALID" type="int">
<generator class="net.sf.hibernate.id.IncrementGenerator">
</generator>
</id>
<property name="level" column="LEVEL" type="int" />
<property name="objectid" column="OBJECTID" type="string" not-null="true" />
<set name="planets" table="PLANET_DBCOMP" cascade="all" lazy="true">
<key column="DBCOMPONENT_ID" />
<many-to-many class="ch.galastria.common.Planet" column="PLANET_ID"/>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
List tempPlanetList = session.find("from Planet as pla where id = ?",
planet.getId(),
Hibernate.LONG);
Planet tempPlanet = (Planet)tempPlanetList.get(0);
HashSet resources = new HashSet();
resources.add(new Dbgcomponent()); //not full just for example (also add properties)
Transaction tx = session.beginTransaction();
tempPlanet.setAccount(user);
tempPlanet.setDbComponents(resources);
session.update(tempPlanet);
session.flush();
tx.commit();
Full stack trace of any exception that occurs:
No errors
Name and version of the database you are using:
SAP DB
The generated SQL (show_sql=true):
Hibernate: insert into DBGCOMPONENT (LEVEL, OBJECTID, TYPEID, TIME2FINISH, INDIVIDUALID) values (?, ?, ?, ?, ?)
Hibernate: insert into DBGCPROPERTIES (PROPVALUE, NAME, DBGOBJECT, ID) values (?, ?, ?, ?)
Hibernate: insert into DBGCOMPONENT (LEVEL, OBJECTID, TYPEID, TIME2FINISH, INDIVIDUALID) values (?, ?, ?, ?, ?)
Hibernate: insert into DBGCPROPERTIES (PROPVALUE, NAME, DBGOBJECT, ID) values (?, ?, ?, ?)
Hibernate: insert into DBGCOMPONENT (LEVEL, OBJECTID, TYPEID, TIME2FINISH, INDIVIDUALID) values (?, ?, ?, ?, ?)
Hibernate: insert into DBGCPROPERTIES (PROPVALUE, NAME, DBGOBJECT, ID) values (?, ?, ?, ?)
Hibernate: insert into DBGCOMPONENT (LEVEL, OBJECTID, TYPEID, TIME2FINISH, INDIVIDUALID) values (?, ?, ?, ?, ?)
Hibernate: insert into DBGCPROPERTIES (PROPVALUE, NAME, DBGOBJECT, ID) values (?, ?, ?, ?)
Hibernate: insert into DBGCOMPONENT (LEVEL, OBJECTID, TYPEID, TIME2FINISH, INDIVIDUALID) values (?, ?, ?, ?, ?)
Hibernate: insert into DBGCPROPERTIES (PROPVALUE, NAME, DBGOBJECT, ID) values (?, ?, ?, ?)
Hibernate: insert into DBGCOMPONENT (LEVEL, OBJECTID, TYPEID, TIME2FINISH, INDIVIDUALID) values (?, ?, ?, ?, ?)
Hibernate: insert into DBGCPROPERTIES (PROPVALUE, NAME, DBGOBJECT, ID) values (?, ?, ?, ?)
Hibernate: update PLANET set TYPE=?, NAME=?, OWNER=? where ID=?
Hibernate: update ACCOUNT set DIPLO=?, LASTACTIVE=?, LASTIP=?, LASTLOGIN=?, NAME=?, POINTS=?, STATE=?, USERMESSAGES=?, ALLIANCE=? where ID=?
Hibernate: update PROPERTIES set EMAIL=?, GRAPHICPATH=?, LOCALE=?, NEWMESSAGES=?, GTIMEZONE=?, USERPASSWORD=? where PropertiesID=?
Hibernate: update PLANET set OWNER=null where OWNER=?
Hibernate: update DBGCPROPERTIES set PROPERTIES=? where ID=?
Hibernate: update DBGCPROPERTIES set PROPERTIES=? where ID=?
Hibernate: update DBGCPROPERTIES set PROPERTIES=? where ID=?
Hibernate: update DBGCPROPERTIES set PROPERTIES=? where ID=?
Hibernate: update DBGCPROPERTIES set PROPERTIES=? where ID=?
Hibernate: update DBGCPROPERTIES set PROPERTIES=? where ID=?
Hibernate: update PLANET set OWNER=? where ID=?
Debug level Hibernate log excerpt:
Debug
|