-->
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: "only inverse 1:M associations" error on non-inver
PostPosted: Thu May 22, 2008 3:11 am 
Newbie

Joined: Thu May 22, 2008 3:01 am
Posts: 1
Location: Brussels
Hibernate version: 3.2

Hi,

I have a parent-child relationship between 2 tables CHARGE and
REMARK (REMARK references CHARGE with an ON DELETE CASCADE
foreign key), here is an excerpt to Charge.hbm.xml:
~<list access="org.jvnet.hyperjaxb2.runtime.hibernate.accessor.ListAccessor"
~ cascade="all" inverse="true"
~ name="Remark"
~ table="Charge_Remark">
~
~ <key on-delete="cascade">
~ <column name="Charge_Remark_Hjid"/>
~ </key>
~
~ <list-index>
~ <column name="Charge_Remark_Hjindex"/>
~ </list-index>
~ <one-to-many class="my.package.Remark"/>
~
~</list>

On line 2 if I remove 'inverse="true"' we ALWAYS get the following error:
# junit.framework.TestListener: addError(testUnmarshal, only inverse one-to-many \
# associations may use on-delete="cascade": my.package.Charge.Remark)

In org.hibernate.mapping.Collection we indeed found the conditions
through which this error is raised:
~ if ( getKey().isCascadeDeleteEnabled() && ( !isInverse() || !isOneToMany() ) ) {
~ throw new MappingException(
~ "only inverse one-to-many associations may use on-delete=\"cascade\": "
~ ...

We HAVEN'T declared the inverse many-to-one in Remark.hbm.xml
mapping file, so how come we have to add 'inverse="true"' in order
for our tests to run fine ??

Obviously from the moment on you use a one-to-many association,
IT MUST be inverse as well (even if the corresponding many-to-one
on the other side is not explicitly specified) or there's something I've
missed ???

(as !isInverse and !isOneToMany BOTH have to be false for the condition
not to be met - eg apparently these 2 one-to-many/inverse properties
are inforced EVEN IF THERE IS NO many-to-one prop defined on the
other end of the relationship -?-)

Thanks a lot in advance,
Seb


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.