-->
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: Inserts instead of updating the record when inverse is true
PostPosted: Tue Apr 30, 2013 10:51 pm 
Newbie

Joined: Tue Apr 30, 2013 10:40 pm
Posts: 2
Hi,
I have a parent table say Table A and i have 3 children to it Table B,C,D

I set all the relationships with Table B,C,D to inverse = true in one-to-many mappings Table A. and have many to one mappings in the child tables (B,C,D)

The child tables B,C,D are only consisting of composite keys with same layout:

Code:
<class
            name="ClassB"
            table="B">
       
        <composite-id>
          <key-property
             name="id"
             column="ID"
             type="long"
          />
           <key-property
               name="col1"
               type="long"
               column="COL1"
           />
           <key-many-to-one
              name="col2"
               column="COL2"
               class="TableA"
              foreign-key="FK1"
           />
        </composite-id>
       
    </class>


same goes for table C, D ....

And in the code i have set all the relationships and everything.. so when i try to update the existing record ... It always inserts a new record. I want to update the existing one..

In the code when i try to update it ... I get the list from the parent.... I clear the list and populate another list with values that come from the UI...add the list for updating... and set it to the parent.. instead of manually going thru the list to update each value... that would be cumbersome... Is there any alternative to it...

Has anyone encountered any similar behaviour.... Kindly let me know

Thanks in advance...


Top
 Profile  
 
 Post subject: Re: Inserts instead of updating the record when inverse is true
PostPosted: Fri May 10, 2013 3:35 am 
Beginner
Beginner

Joined: Thu May 17, 2007 9:56 am
Posts: 21
Location: India
Can you try to check the values of insert and update properties in your mapping file?, By default if not specified they will be true. We can check the functionality by changing it to "insert=false". It is just a suggestion.

_________________
Kuzhali


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.