-->
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: Unerklaerliches Verhalten beim Loeschen von many-to-many Rel
PostPosted: Thu Nov 27, 2008 7:04 pm 
Newbie

Joined: Thu Nov 27, 2008 6:43 pm
Posts: 2
Hallo zusammen,

Ich habe ein sehr seltsames und fuer mich unerklaerliches Verhalten von Hibernate bei einem bestimmten mapping.

Also ich habe folgende Mappings :

-----------------------------------------------------------------------------------
<hibernate-mapping>
<class name="CreativeUrl" table="CUC">

<id name="creativeUrlId" column="ID_CUC" type="long">
<generator class="identity"/>
</id>

...

<set name="creatives" table="CUC_2_CREATIVE" inverse="false" cascade="save-update,delete">
<key column="ID_CUC" not-null="true"/>
<many-to-many column="ID_CREATIVE" class="Creative"/>
</set>

</class>
</hibernate-mapping>


<hibernate-mapping>
<class name="AdvertisementCreativeUrl" table="CUC_2_ADVERTISEMENT">

...

<many-to-one name="creativeUrl" column="ID_CUC" not-null="true" class="CreativeUrl" update="false" insert="false"/>

</class>
</hibernate-mapping>
----------------------------------------------------------------------------------

Beim

CreativeUrl creativeUrl = new CreativeUrl();
creativeUrl.addCreative(_creative1_);
creativeUrl.addCreative(_creative2_)
CreativeUrlDao.save(creativeUrl);

und danach

AdvertisementCreativeUrlDao.save(new AdvertisementCreativeUrl())
AdvertisementCreativeUrlDao.deleteAll() (mach einfach delete from .... ohne where klause)

beobachte ich beim eingeschaltete SQL-Ausgabe folgendes :

insert into CUC (NAME_CUC, DELIVERY_SHARE, STATE_CUC, ID_CAMPAIGN, ID_URL) values ('', 0, 2, 15, 15)
insert into CUC_2_CREATIVE (ID_CUC, ID_CREATIVE) values (18, 29)
insert into CUC_2_CREATIVE (ID_CUC, ID_CREATIVE) values (18, 30)

delete from CUC_2_ADVERTISEMENT
delete from CUC_2_CREATIVE where ID_CUC=18
delete from CUC_2_CREATIVE where ID_CUC=18

Also offensichtlich "triggert" der statement
delete from CUC_2_ADVERTISEMENT
die anderen beiden delete-statements, was fuer mich ziemlich verwirrend ist.
Meine Frage ist :
Wie kann ich verhindern dass der die letzten beiden delete automatisch passieren?

Waere sehr dankbar wenn mir jemand hilft :-)


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.