Look at this mapping

<bag name="searchDefinition" access="field" cascade="all-delete-orphan" table="RawSearchDefinition" fetch="join"> <key column="ParentObjectId" /> <composite-element class="RawSearchDefinition"> <property name="ExcludeKeyword" column="raws_excludeKeyword" type="String" /> <property name="IncludeKeyword" column="raws_includeKeyword" type="String" /> </composite-element> </bag>

It seems ok but it has a subtle error, when you try to save the object,  a “collection was not an association” error will arise. This error is derived from the cascade=”all-delete-orphan”, this attribute is used for real entity object not value ones. A mapping with composite element does not need cascade, the RawSearchDefinition is a value object, its lifecycle will span that of the owner.

The solution is simply to remove cascade attribute, that is not required.

alk.

Tags:

kick it on DotNetKicks.com


kick it on DotNetKicks.com

Leave a Reply