-->
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: Hibernate stucks, "UPDATE" instead of "INSERT
PostPosted: Thu Jun 09, 2005 7:48 am 
Newbie

Joined: Tue May 17, 2005 4:54 am
Posts: 15
Location: Germany, Karlsruhe
Hello,

I have a bidirectional association problem.
The association is one-to-many: 1 "Projekt" has 0..* "Kunden".

Now consider the mapping for "Projekt":

Code:
      <set name="kunden" cascade="all" lazy="true">
          <key column="id" />
           <one-to-many class="Kunde"/>
   </set>


The "Kunden"-Klass itself consists of a composite-key (created by MyEclipse, but I found no better solution):

Code:
<class name="Kunde" table="kunden">
        <composite-id name="id" class="KundenKey">
       
            <key-many-to-one name="projekt" column="projekte_Id" class="Projekt"/>
            <key-many-to-one name="firma"   column="firmen_Id"     class="Firma"/>

            <!--
            <key-property name="projekt" column="projekte_Id" />
            <key-property name="firmen" column="firmen_Id" />
            //-->
        </composite-id>



As you can see there it's a unidirectional association.


Now to the problem.
I want to make an object of the class "Projekt" persistent:

Projekt p = new Projekt(); // parent class
p.setKunden(kunden); // add the "children"
res = addProject(p); // does: session.save(p);

1) If I have cascade="all" or "all-delete-orphan", the projekt is inserted (thats OK), but then Hibernate stucks and I don't get any response from the webserver. No error messages either.

2) If I have cascade="save-update" (or even the same with "none"), the projekt is inserted (thats OK as well). Additionally, Hibernate tries to UPDATE rows in the Kunden-table instead of INSERTing them!
This rises an error, of course, because there are no rows to update available. They have to be inserted first.


Does any have some advice?

Or, do I have to insert the kunden-class manually?
Actually I'm looking for the parent-children-solution.

Thanks for your help,
George


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 09, 2005 7:49 am 
Newbie

Joined: Tue May 17, 2005 4:54 am
Posts: 15
Location: Germany, Karlsruhe
sorry for the contradiction in my 1st post, it's indeed a unidirect. association ... not bidirectional.


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.