-->
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: I can do inserts but I cant do querys. I would appreciate an
PostPosted: Tue Jan 10, 2006 1:07 pm 
Newbie

Joined: Tue Jan 10, 2006 11:56 am
Posts: 2
Location: Madrid / Spain
Hi all,

I have problems with a many-to-many associations, I can do inserts but I cant do querys. I obtain ever the same exception. I havbe test with lazy = "false", outer-join="true" but the same. I would appreciate any help.

Thanks


Rodolfo


Hibernate version: 3.0.5

Mapping documents:
<class name="com.mdagen.rallie.model.Equipo" table="EQUIPOS">
...
<set name="marcas" cascade="save-update"
table="EQUIPOS_MARCAS">
<key column="NUMERO"/>
<many-to-many class="com.mdagen.rallie.model.Marca"
column="ID_MARCA"/>
</set>
...
</class>
_______________

<class name="com.mdagen.rallie.model.Marca" table="MARCAS">
...
<set name="equipos" inverse="true" cascade="save-update"
table="EQUIPOS_MARCAS">
<key column="ID_MARCA"/>
<many-to-many class="com.mdagen.rallie.model.Equipo"
column="NUMERO"/>
</set>
</class>

Code between sessionFactory.openSession() and session.close():
...
result = (Marca)getHibernateTemplate().load(Marca.class, idMarca);
Hibernate.initialize(resultado.getEquipos());
...

Full stack trace of any exception that occurs:
2006-01-10 15:38:33 StandardWrapperValve[action]: Servlet.service() para servlet action lanzó excepción
org.hibernate.LazyInitializationException: illegal access to loading collection at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:172)

Name and version of the database you are using:
mysql 4.1


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 9:51 am 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
Hi,

*full stacktrace*, not last 2 lines :)

Assuming this is what am thinking it is....

This error at object loading time is quite typical to an object trying to modify linked objet during Hibernate initialisation process.

example:
Code:
Class A {
Set B
setB(Set bs){
    ...
    // For some b in bs
    b.setSomeRelationToA(this);
}


You can not modify other classes that can be potentially managed by hibernate inside a setter accessed by hibernate. A setter is made to set a value. If it begin to modify other object, then it is not a setter anymore.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 1:14 pm 
Newbie

Joined: Tue Jan 10, 2006 11:56 am
Posts: 2
Location: Madrid / Spain
thanks,

my POJO code class is :

public class Marca ... {
....
private Set equipos;
....

public setEquipos(Set data) {
this.equipos = data;
}
...
}
_____________

public class Equipo ... {
...
private Set marcas;
....

public setMarcas(Set data) {
this.marcas = data;
}
...
}

I think the problem could be other than you say because I don´t do any set into my set methods.

The other exceptions are exception from catalina, struts and tomcat I think this full stack don´t give very much information.

What the solution do you think I could do.


Thanks Rodolfo


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 23, 2006 5:41 am 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
Again, stacktrace!


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.