-->
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.  [ 4 posts ] 
Author Message
 Post subject: expected type: java.util.ArrayList
PostPosted: Tue Sep 06, 2005 7:52 am 
Newbie

Joined: Fri Sep 02, 2005 12:47 pm
Posts: 14
Location: muenchen
I try to mape parent - child relation using llist.
In parent class I have ArrayList object holding children

I got this error...

13:39:11,036 ERROR BasicPropertyAccessor:62 - IllegalArgumentException in class: data.object.pdbCode, setter method of property: pdbfiles
13:39:11,036 ERROR BasicPropertyAccessor:66 - expected type: java.util.ArrayList, actual value: org.hibernate.collection.PersistentList

Both getter and setter for in parent class operate obviosly on ArrayList why this is a problem?

My mapping on parent side looks like:

<list name="pdbfiles"
lazy="true"
inverse="true"
cascade="all-delete-orphan">

<key column="parent_id" not-null="true"/>
<list-index column="number"/>
<one-to-many class="pdbFile"/>
</list>


and on children side:

<many-to-one name="parent_id"
class="pdbCode"
column="parent_id"
not-null="true" />

Any suggestions ?


Sincerely,

Pawel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 06, 2005 8:00 am 
Senior
Senior

Joined: Thu Aug 04, 2005 4:54 am
Posts: 153
Location: Birmingham, UK
Do not have your setter method taking ArrayList, have it use the interface List instead so that a persisted list can be used as well.
Code:
public void setChildren(Set children){
this.children = children;
}


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 06, 2005 8:07 am 
Newbie

Joined: Fri Sep 02, 2005 12:47 pm
Posts: 14
Location: muenchen
Thanks,




private void setSmt(List p) {
this.Smt = (ArrayList) p;
}


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 06, 2005 8:33 am 
Senior
Senior

Joined: Thu Aug 04, 2005 4:54 am
Posts: 153
Location: Birmingham, UK
You don't actually even need that cast, and really you shouldn't use it.

Define your property using the Interface leaving you free to choose the implementation and alter it if necessary.

Code:
public class Site(){
private List invoices = new ArrayList();

public Site(){
}

public void setInvoices(List invoices){
this.invoices = invoices;
}

public List getInvoices(){
return invoices;
}


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