-->
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.  [ 5 posts ] 
Author Message
 Post subject: composite-element
PostPosted: Mon Dec 03, 2007 10:29 am 
Beginner
Beginner

Joined: Tue Mar 27, 2007 4:54 am
Posts: 47
Hibernate version:
1.2.1

Hi

I cannot get the composite-element to work. Whenever it'll get persisted I get a MappingException - "collection was not an association".

<class ...>
....
<bag name="OpenHourList2"
cascade="all-delete-orphan">
<key column ="Parent" />
<composite-element class="[xxx].TimePeriod" >
<property name="StartTime" />
<property name="EndTime" />
</composite-element>
</bag>
....
</class>

Does someone recognize this problem? Am I missing something? Is it a bug?

Regards
Roger


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 03, 2007 11:17 am 
Beginner
Beginner

Joined: Tue Mar 27, 2007 4:54 am
Posts: 47
(As usual ;)) I found out what caused the problem too late. After I wrote the issue, I found out that the cascading messed things up. When this attribute was removed - things started to work correctly.

However - this must surely be a bug? I'm fully aware that a collection of components might be seen as "part of the entity" (the same a component is), but that this throws a strange exception doesn't make sense.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 03, 2007 11:34 am 
Beginner
Beginner

Joined: Tue Mar 27, 2007 4:54 am
Posts: 47
To make things clearer(?)... The problem occurs if all-delete-orphan is set on the bag holding the composite-element


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 03, 2007 8:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
Specifying "cascade" is erroneous for a "composition" (in UML's sense). That is, the parent owns the children; therefore, cascading is implicitly all-delete-orphan and specifying it explicitly is only allowed when the elements of the collection are entities in their own rights.

_________________
Karl Chu


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 04, 2007 4:06 am 
Beginner
Beginner

Joined: Tue Mar 27, 2007 4:54 am
Posts: 47
Yes, understood. Thanks.


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