-->
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: Problem with storing list of objects..
PostPosted: Wed Nov 02, 2005 7:02 pm 
Beginner
Beginner

Joined: Wed Oct 19, 2005 12:03 pm
Posts: 21
Hi,

I have a class that contains another class

public class VehicleOperation implements Serializable
{
protected ProfileContainer profileContainer = new ProfileContainer();

void setProfileContainer(ProfileContainer profileContainer)
{
this.profileContainer = profileContainer;
}
public ProfileContainer getProfileContainer()
{
return profileContainer;
}
}

The inner class has a linked list of objects ..

public class ProfileContainer implements Serializable {

LinkedList<Profile> completedProfiles = new LinkedList<Profile>();

public Collection<Profile> getCompletedProfiles()
{
return completedProfiles;
}
public void setCompletedProfiles(LinkedList<Profile> completedProfiles)
{
this.completedProfiles = completedProfiles;
}
}

my mapping files look like this:

<class name="VehicleOperation" table="ve_op" optimistic- lock="none">
<id name="voId" type="integer" unsaved-value="null" column="vo_id">
<generator class="native"/>
</id>
<one-to-one name="profileContainer" cascade="save-update"
fetch="join" lazy="false" entity
name="ProfileContainer"/>
</class>

<class name="ProfileContainer" table="profile_container" optimistic-
lock="none">
<id name="id" type="integer" unsaved-value="null" column="id">
<generator class="native"/>
</id>
<list name="completedProfiles" cascade="all">
<key column="profileId"/>
<list-index>
<column name="profileIndex" not-null="true"/>
</list-index>
<one-to-many entity-name="Profile"/>
</list>
</class>
</hibernate-mapping>

When I try to save the VehicleOperation object vOP
session.save(vOp);
I want the profileContainer with the profiles to be saved also.
It gives me an exception

- IllegalArgumentException in class: setter method of property: completedProfiles
16500 [AWT-EventQueue-0] ERROR org.hibernate.property.BasicPropertyAccessor - expected type: java.util.LinkedList, actual value: org.hibernate.collection.PersistentList

org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of ProfileContainer.completedProfiles


Is there a problem with my mapping or with the way im saving it. How shud I do it.????

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 02, 2005 7:21 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
My first thought, given your java code, is that you shouldn't be using an explicit LinkedList. This is probably the problem, but even if it isn't, it's just a bad design. Use a List instead. The only place LinkedList should be used is with the new operator.

Presumably hibernate's PersistentList implements List but doesn't extend LinkedList.


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.