Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:2.1.6
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:postgres 8.0
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Hello World
i have a pb
with a composite element and update :
i have 4 tables
groupe_utilisateur(pk gru_id) ------ gru_obj----------objet(pk obj_id)
|
|
droit(pk droit_id)
gru_obj is a link table compose with :
gru_id, obj_id, droit_id
gru_id, obj_id are composite pk
may mapping file composite is
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!-- Created by the Matta generator hibernate mapping -->
<!-- genere par HBXMLWriter.java -->
<class name="app.hb.GruObj" table="gru_obj">
<composite-id name="comp_id" class="app.hb.GruObjPK" unsaved-value="none">
<key-property
name="obj_id"
column="obj_id"
type="java.lang.Integer"
length="4"
/>
<key-property
name="gru_id"
column="gru_id"
type="java.lang.Integer"
length="4"
/>
</composite-id>
<!--bi-directional many-to-one gru_obj to objet -->
<many-to-one
name="objet_obj_id"
class="app.hb.Objet"
not-null="true"
update="false"
insert="false"
>
<column name="obj_id" />
</many-to-one>
<!--bi-directional many-to-one gru_obj to groupe_utilisateur -->
<many-to-one
name="groupe_utilisateur_gru_id"
class="app.hb.GroupeUtilisateur"
not-null="true"
update="false"
insert="false"
>
<column name="gru_id" />
</many-to-one>
<!--bi-directional many-to-one gru_obj to droit -->
<many-to-one
name="droit_droit_id"
class="app.hb.Droit"
not-null="true"
update="false"
insert="false"
>
<column name="droit_id" />
</many-to-one>
</class>
</hibernate-mapping>
and
for table groupe_utilisateur
.........
<!-- bi-directional one-to-many groupe_utilisateur to gru_obj -->
<set
name="gru_obj_gru_ids"
table="gru_obj"
lazy="false"
inverse="true"
cascade="all" outer-join="false"
>
<key>
<column name="gru_id" not-null="true" />
</key>
.......
when i change a value from groupe_utilisateur no pb update OK
when i change a value of gru_obj droit_id for exemple nothing append
(and i am sad)
when i set unsaved-value="any" to the composite mapping file
update generate a insert into ... pk violation ...
Why ? if hibernate can generate a insert into ... why don't it don't
generate a update with unsaved-value="none" ?
Thank's for your idear's