-->
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: Collection was evicted
PostPosted: Thu Oct 06, 2005 9:16 am 
Newbie

Joined: Thu Jul 21, 2005 9:56 am
Posts: 3
Hello, I have this problem with my object, when I try to add a element to a List in the Object, Hibernate say:

org.hibernate.HibernateException: collection was evicted
org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:40)
org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1430)
org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:176)
org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:48)
org.hibernate.collection.PersistentBag.toArray(PersistentBag.java:250)
java.util.ArrayList.addAll(ArrayList.java:434)

<b>The XML Object:</b>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
.
.
.
<bag name="listaEstados"
table="lista_estados_carta_porte"
cascade="all" lazy="true">
<key>
<column name="nro_sucursal" unique="true"/>
<column name="nro_carta_porte" unique="true"/>
</key>
<one-to-many class="ListaEstadosCartaPorte"/>
</bag>

<b>The bean Object</b>

public class CartaPorte implements Serializable
{
.
.
private List listaEstados;
etc, etc....

the problem is this code:

List listaEstadosCP = new ArrayList();
listaEstadosCP.add(cp.getListaEstados()); <----- HERE

please, i need help with this....

Hibernate version: 3

Mapping documents: 3


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 09, 2005 9:15 am 
Beginner
Beginner

Joined: Sat Oct 08, 2005 2:13 am
Posts: 47
hi
as far as I know u cant add a list to a list using add() method

u must use addAll() method

listaEstadosCP.addAll(cp.getListaEstados()); <----- HERE


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.