-->
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: update problems -- composite elements
PostPosted: Fri Sep 16, 2005 1:51 pm 
Newbie

Joined: Fri Sep 16, 2005 1:44 pm
Posts: 10
Location: France (Paris)
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


Top
 Profile  
 
 Post subject: graph
PostPosted: Sat Sep 17, 2005 8:01 am 
Newbie

Joined: Fri Sep 16, 2005 1:44 pm
Posts: 10
Location: France (Paris)
new correct graph

groupe_utilisateur(pk gru_id) === gru_obj=====objet(pk obj_id)
........................................................||
........................................................||
................................................droit(pk droit_id)


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.