-->
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.  [ 3 posts ] 
Author Message
 Post subject: Does cascade="none" work in component?
PostPosted: Mon Aug 23, 2004 2:07 pm 
Beginner
Beginner

Joined: Tue Mar 23, 2004 8:40 pm
Posts: 22
Folks,

I tried to insert a new record (with two many-to-one associations, first one is a pure simple many-to-one association, second one is within a component). However, it looks like the setting cascade="none" has no effect on the second many-to-one association (i.e. one within the component) and Hibernate generates the TransientObjectException, any ideas?

P.S.
The first many-to-one association works fine (with cascade="none" too) which Hibernate would ignore it during the insert.

Thanks in advance!

Martin

Hibernate version:
2.1.6

Mapping documents:
Code:
    <many-to-one name="commodity" column="COMMODITYOBJID" class="global.vo.CommodityVO"
      cascade="none"/>
    <component name="cmv" class="global.jb.Cost">
      <many-to-one name="currency" column="CMVCURRENCY_GNLUOBJID" class="global.vo.CurrencyVO"
        cascade="none"
        outer-join="false"
        />
      <property name="amount" column="CMVAMOUNT" type="double"/>
    </component>


Code between sessionFactory.openSession() and session.close():
Code:
        addedObject = session.saveOrUpdateCopy(vo);
        session.flush();


Full stack trace of any exception that occurs:
Code:
net.sf.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: global.vo.CurrencyVO



Name and version of the database you are using:
Oracle 8.1.7

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 2:59 pm 
Regular
Regular

Joined: Mon Oct 06, 2003 7:17 am
Posts: 58
Location: Switzerland
When you define a component, it means you have a relationship with an value object. This means the lifcycle of your entity and the value object are the same. So in this case it makes no sense to define a many-to-one relationship or to define a cascade = none. From this point it makes sense when it ignores the cascade in a component.

Reto


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 4:46 pm 
Beginner
Beginner

Joined: Tue Mar 23, 2004 8:40 pm
Posts: 22
Thanks for your reply, any suggestion to ignore the many-to-one assoication within the component during insert/update/delete?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.