-->
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: cascade doesn't work when using generator=sequence-identity?
PostPosted: Wed Jul 14, 2010 9:53 pm 
Newbie

Joined: Wed Jul 14, 2010 8:52 pm
Posts: 1
Context:
1) We're newbies.
2) We're mapping two entities, Order & ContactInfo. Order has a reference to ContactInfo. Many different Orders can reference the same ContactInfo, i.e. it's a many-to-one relationship. We use Oracle 10g and sequences for our primary keys. As such, we used the following generator configuration:

<generator class="org.hibernate.id.enhanced.SequenceStyleGenerator">
<param name="sequence_name">ORDER_INFO_SEQ</param>
</generator>

However, we found that when we save a new Order instance, this causes a SELECT to be performed on the sequence in order to get a new PK, and then an INSERT performed with that new PK. We later discovered that we could inline the call to get the next value of the sequence inside of the INSERT statement if we switched the generator to the following:

<generator class="sequence-identity">
<param name="sequence">ORDER_INFO_SEQ</param>
</generator>

However, when we do that it appears that our cascade="persist, merge, save-update" on the Order to ContactInfo relationship no longer works. Instead we see the following exception:

org.hibernate.PropertyValueException: not-null property references a null or transient value: com.acme.entity.OrderInfo.userContactInfo

By the cascade no longer working the use case that causes this behavior is essentially:

--start Tx
Order o = new Order();
ContactInto c = new ContactInfo();
o.setContactInfo(c);
getSession().save(o);
--end Tx

Does anyone have an explanation for this behavior or is this possibly a bug?

Thanks,
O


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.