-->
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.  [ 4 posts ] 
Author Message
 Post subject: HOWTO Update Composite-id
PostPosted: Fri May 21, 2004 2:49 pm 
Newbie

Joined: Sat May 15, 2004 2:53 am
Posts: 2
Hello Fellows, i'm a beginner, i really like to know why hibernate can not update my object.
i use load + set + commit and nothing happens
i need to update a value that is inside a composite id then, i know constraints about Relational Model.
but if you put as example in TOAD:

UPDATE cpvanchdba.oabb445t_veiculos_x_peca_jit
SET PKSV_445PECA = 'OLDPK'
WHERE PKNI_445NSEQPROG = '1318001'
and PKSV_445PECA = 'NEWPK'

it's works ok, so when i try to doing with hibernate i can't i'm using ORACLE DB, Hibernate 2.1.2 and i my project is advanced,
and i can update data but no id data.... thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 21, 2004 7:55 pm 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
Could you give your mapping files with the composite id and relationship.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 10:50 am 
Newbie

Joined: Sat May 15, 2004 2:53 am
Posts: 2
this is the mapping:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="com.vw.finetuning.bo.PiezasBean" table="CPVANCHDBA.OABB445T_VEICULOS_X_PECA_JIT">

<composite-id name="piezasPK" class="com.vw.finetuning.bo.PiezasPK">
<key-property name="anio" column="PKNI_445ANO" type="java.lang.String"/>
<key-property name="site" column="PKSV_445SITE_VW_SEQ" type="java.lang.String"/>
<key-property name="knr" column="PKNI_445NSEQPROG" type="java.lang.String"/>
<key-property name="peca" column="PKSV_445PECA" type="java.lang.String"/>
</composite-id>

<property name="forn" column="ATSV_445FORNECEDOR" type="java.lang.String"/>
<property name="data" column="ATDT_445DATA_REC_BESI"/>
<property name="uso" column="ATSV_445USO" type="java.lang.String"/>


</class>

</hibernate-mapping>

i don't need to update in cascade, because i only need modify pksv_445PECA field. thank's!


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 11:57 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
i don't need to update in cascade,


do you have other objects linked to this one by some association?

updating primarey key is not really nice but i think you don't have the choice.

Instead of load + set + commit you should try load + new instance + copyAllProperties + set the key you want to modify + save(newObj) + delete(oldObj) + commit

In my opinion it's more OO logic even if it seems a little bit complicated

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.