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.  [ 2 posts ] 
Author Message
 Post subject: Bags in component
PostPosted: Tue Feb 13, 2007 5:17 am 
Newbie

Joined: Tue Feb 13, 2007 5:11 am
Posts: 1
Hi,

I use Hibernate 3.2.2 GA.
I have a strange comportment with bags in component.

A use a mapping including a component having a bag inside :

<class name="SynchoServiceOrder" table="DS_ORDER" lazy="true">
<component name="periodicity" class="PeriodicityPeriod">

<property column="PERIODICITY_SHIFT"
name="shift"
type="integer"/>

......

<bag name="exceptionsBag" cascade="all-delete-orphan" >
<key column="EXCEPTIONS_PID" />
<one-to-many entity-name="SynchroTimePeriodDeleted" />
</bag>
</component>
</class>

This periodicity is included in a parent object and may be null. In this case, I dont want to store default values from periodicity but null values in the table DS_ORDER. So periodicity object has a method isNullObject() to detect null components :

if ( synchroServiceOrder.getPeriodicity().isNullObject() )
synchroServiceOrder.setPeriodicity(null);

This works fine for all my components except for components having a bag inside.

When I use a merge to save my objects, Hibernate detects that database object has a periodicity (instanciated by Hibernate) and has instanicated an empty exceptionsBag list inside. But in fact this periodicity does not exists, it is an null object in the persisted object. So when I flush the session, I have the error :
A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance SynchoServiceOrder.

The merge has detected that the database object has a list not null and the object to persit has a null list. As the status is not delete, Hibernate supose that the list was set to null explicitly, and return an error.

Hibernate does consider that an empty list is dereferenced if new entity has null list. On a standard mapping, I wouldn't have problem as the parent object of the list exists, but for component, in my context, there is not parent so no possibility to return Collections.EMPTY_LIST if list is null.

The solution I found is to put the bag in the parent object (SynchoServiceOrder) but it can work only for tests, not definitively.

I hope I’ve been clear. Is there a solution for that problem ?

Thanks.


Top
 Profile  
 
 Post subject: Re: Bags in component
PostPosted: Wed Aug 29, 2012 3:15 am 
Newbie

Joined: Thu Jun 17, 2010 10:41 am
Posts: 3
Have about the same problem, Hibernate 3.5. Did you find any solution?


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