-->
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.  [ 1 post ] 
Author Message
 Post subject: SQL insert, update or delete failed (row not found)-Third
PostPosted: Fri Mar 26, 2004 4:58 am 
Newbie

Joined: Mon Mar 22, 2004 11:36 am
Posts: 7
Ok,

I solved my trouble which I described here.
http://forum.hibernate.org/viewtopic.php?t=929308

What have i do?

My two tables wit the one-to-many relation lookes like this

------------------------------------------
Table..|Auftrag...........|Auftragattribut
------------------------------------------
row....|auftragnr(PK).....|auftragnr(FK)
row....|auftrgdatum.......|.....
row....|..................|...
row....|..................|..
row....|..................|.
row....|..................|.
row....|..................|.

The problem was, that the Auftragattribut table had no own PK.
After I put in this table an own PK it works fine.
But the reason didn't unterstand until now.
Through the view of the Database Management System there is
no problems create Two tables and join the in this way.
Every one Table A row has his own n Table B Row, which can be find
with the auftragnr row.

If anybody can enlight me in this Point I were very happy.
This stupid flaw gave me a lot of trouble.


Taner.



Below the Version which is now working.

----------------------------------------------
Table..|AuftragTest.......|AuftragattributTest
----------------------------------------------
row....|auftragnr(PK).....|attnr(PK)
row....|auftrgdatum.......|auftragnr(FK)
row....|..................|......
row....|..................|.....
row....|..................|....
row....|..................|...
row....|..................|..



the hbm.xml

<?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="net.comp.enterprise.test.Auftrag" table="AuftragTest" dynamic-update="false" dynamic-insert="false">
<id name="auftragnr" column="auftragnr" type="integer">
<generator class="sequence">
<param name="sequence">Auftrag_Seq</param>
</generator>
</id>
<property name="auftragdatum".......type="timestamp"..update="true" insert="true" column="auftragdatum"/>
<property name="auftragtermin"......type="date".......update="true" insert="true" column="auftragtermin"/>
<property name="auftragstatus"......type="string".....update="true" insert="true" column="auftragstatus"/>
<property name="auftraggebernr".....type="string".....update="true" insert="true" column="auftraggebernr"/>
<property name="extauftragnr".......type="string".....update="true" insert="true" column="extauftragnr"/>
<property name="extprojektnr".......type="string".....update="true" insert="true" column="extprojektnr"/>
<property name="bezeichnung"........type="string".....update="true" insert="true" column="bezeichnung"/>
<property name="vertragspartner"....type="string".....update="true" insert="true" column="vertragspartner"/>
<property name="bereitstellungsart".type="string".....update="true" insert="true" column="bereitstellungsart"/>
<property name="geaendert"..........type="timestamp"..update="true" insert="true" column="geaendert"/>
<property name="geaendert_durch"....type="string".....update="true" insert="true" column="geaendert_durch"/>

<set name="auftragattribute" table="AuftragAttributTest" lazy="false" inverse="false"
cascade="all" sort="unsorted">
<key column="auftragnr"/>
<one-to-many class="net.comp.enterprise.test.Auftragattribut"/>
</set>
</class>

<class name="net.comp.enterprise.test.Auftragattribut" table="AuftragAttributTest" dynamic-update="false" dynamic-insert="false">
<id name="attnr" column="attNr" type="integer" unsaved-value="0">
<generator class="sequence">
<param name="sequence">AuftragAuftragAttribut_Seq</param>
</generator>
<!-- <generator class="assigned"/> -->
</id>
<many-to-one name="auftrag" class="net.comp.enterprise.test.Auftrag" column="auftragnr" update="false" insert="false"/>
<property name="auftragnr"....type="integer".update="true" insert="true" column="auftragnr"/>
<property name="attributnr"...type="integer".update="true" insert="true" column="attributnr"/>
<property name="attribut".....type="integer".update="true" insert="true" column="attribut"/>
<property name="wert".........type="string"..update="true" insert="true" column="wert"/>
<property name="langwert".....type="string"..update="true" insert="true" column="langwert"/>
<property name="ausschluss"...type="char"....update="true" insert="true" column="ausschluss"/>
<property name="extauftragnr".type="string"..update="true" insert="true" column="extauftragnr"/>
</class>
</hibernate-mapping>

Now I can save in this kind, which was not possible before this change with the tables.

Auftrag auft = new Auftrag();
auft.setAuftragdatum(new Timestamp(System.currentTimeMillis()));
.......
....
..
.


Set attSset = new HashSet();
Auftragattribut att = null;

for(int i=0; i < 100;i++){
att = new Auftragattribut();
att.setExtauftragnr("Ext AuftNR");
.........
....
}

auft.setAuftragattribute(attSset);
session.save(auft);


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.