-->
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: Don't dereference a collection with cascade="all-delete
PostPosted: Wed Apr 27, 2005 10:01 pm 
Newbie

Joined: Mon Jun 14, 2004 4:47 am
Posts: 7
our API is such that we don't generate setter methods for collections but simply do a getBars().add(new Bar())...
for that we thought we could provide a DirectPropertyAccessor subclass,
that does:

Getter getter = new TxeCollectionDirectGetter( field, clazz, name );
Collection collection = (Collection ) getter.get( target );
collection.clear();
collection.addAll(value);

that did not work. It gave us the error "Don't dereference a collection with cascade="all-deleteorpha..."

so now we are trying to understand exactly what the setter should do:
- Is the idea that the setter should accept a hibernate.PersistentBag instance which is what is passed in public void set(Object target, Object value, SessionFactoryImplementor factory) method?

Just to test this we did implement a setter method as follows:

public List getAggs() {
if (aggs == null) {
aggs = new EObjectContainmentWithInverseEList(OrderEntryElement.class, this,..); }
return aggs;
}


public void setAggs(List list){
aggs = new EObjectContainmentWithInverseEList(OrderEntryElement.class, this, ...);
aggs.addAll(list);
}


with the following Mapping documents:
<class name="orderentry.impl.OrderEntryElementImpl" table="OrderEntryElement">
... <many-to-one name="aggby" class="orderentry.impl.ModelImpl">
<column name="aggby_Model" not-null="true"/>
</many-to-one>
...
</class>
<class name="orderentry.impl.ModelImpl" table="OrderEntryModel">
<id name="modelID" type="long" column="modelID" unsaved-value="0">
<generator class="native"/>
</id>
<bag name="aggs" access="field" inverse = "true" cascade="all-delete-orphan">
<key column="aggby_Model"/>
<one-to-many class="orderentry.impl.ElementImpl"/>
</bag>
</class>

this is not working either. we are now getting "could not set a field value by reflection setter" error.

Are we not allowed to use custom collection class as described above?

thanks in advance,
kagan


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.