-->
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.  [ 6 posts ] 
Author Message
 Post subject: Problem removing objects from a set, tried everithing...
PostPosted: Thu Sep 25, 2003 6:44 am 
Newbie

Joined: Thu Sep 25, 2003 6:17 am
Posts: 4
Hi,
I,ve got these two classes that have a many-to-many relationship :
Usuario<----->Modulo
so there is a UserModule table that contains data.

Usuario class has a Set of Modulos.
I can successfully add modules to any user, but I can


Top
 Profile  
 
 Post subject: More info
PostPosted: Thu Sep 25, 2003 7:41 am 
Newbie

Joined: Thu Sep 25, 2003 6:17 am
Posts: 4
Yes it


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 25, 2003 8:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Can you post your mapping for the Usuario class, especially the portion defining the relation to Modulo, and the Modulo class mapping.

Does Modulo have a reference to Usuario?

What does your hashCode() method look like?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 25, 2003 10:09 am 
Newbie

Joined: Thu Sep 25, 2003 6:17 am
Posts: 4
Ok, Usuario:

<hibernate-mapping>
<class
name="org.siia.aplicaciones.siiadmin.Usuario"
table="USUARIOS_GIS"
proxy="org.siia.aplicaciones.siiadmin.Usuario"
>

<id
name="id"
column="C_USUARIO"
type="long"
unsaved-value="0"
>
<generator class="sequence">
<param name="sequence">usuario_seq</param>
</generator>
</id>

<property
name="administrador"
type="boolean"
update="true"
insert="true"
column="L_ADMISTRADOR"
not-null="true"
/>

<set
name="modulos"
table="USUARIOS_MODULOS"
lazy="true"
inverse="false"
cascade="all"
sort="unsorted"
>

<key
column="USUARIO_ID"
/>

<many-to-many
class="org.siia.aplicaciones.siiadmin.Modulo"
column="MODULO_ID"
/>

</set>
.
.
.

And Modulo doesn


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 25, 2003 10:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Remember that the proxy is a different object! Accessing its instance variables directly in equals() is just not going to work. Use the getter.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 25, 2003 10:24 am 
Newbie

Joined: Thu Sep 25, 2003 6:17 am
Posts: 4
THAT WAS IT!!!!

I was using something like this in equals:

...
if ( m.id == id )
return true;


So it was wrong, the correct thing is:

if ( m.getId() == getId() )
return true;

Now, it works
Thank you very much you all!!!!


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