-->
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: Owned collection not inserting
PostPosted: Tue Aug 27, 2013 1:47 pm 
Newbie

Joined: Wed Sep 10, 2008 2:02 pm
Posts: 14
Location: NJ
I have the following 2 entities:

User
CreditCard

User is defined with this mapping:
Code:
        <set name="creditCards"
            inverse="true"
            order-by="creditcardid desc" cascade="save-update, lock">
            <key column="username" not-null="true"/>
            <one-to-many class="CreditCard"/>
        </set>

CreditCard is mapped like this:
Code:
        <many-to-one name="member" column="username" not-null="true"/>

A user can have many credit cards. A credit card can only belong to a single User.

At run-time, I load a persistent User, looking it up by primary key.
A new credit card is then added like this:
Code:
user.addCreditCard(creditCard);

In the User class:
Code:
public void addCreditCard(CreditCard creditCard) {
    this.getCreditCards().add(creditCard);
    creditCard.setMember(this);
}

When the transaction commits, i.e., the one that loaded the User instance, no insert into the credit_cards table occurs. Inspecting the user's creditCards collection from within the debugger during the transaction indicates that it is marked dirty. The user is not modified in any other way.

Can anyone tell me what the reasons might be for the credit card collection not being updated when the transaction commits?

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Owned collection not inserting
PostPosted: Tue Aug 27, 2013 2:23 pm 
Newbie

Joined: Wed Sep 10, 2008 2:02 pm
Posts: 14
Location: NJ
I wish I could quit asking this question. Once again I have found that adding the "all" option to cascade solves the problem. Is cascade="all, save-update" redundant? Does all obviate save-update? I'm guessing it does.


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.