-->
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: Really Weird!!!! Check it out!!
PostPosted: Wed Sep 22, 2004 10:08 pm 
Beginner
Beginner

Joined: Sun Jun 20, 2004 11:39 pm
Posts: 24
I am facing a really weird problem with removing a element from a hashset , with the element coming from the hashset itself

This is the results i am getting:
-------------------------------------
before user.getSimpleMessageServiceMessages().size():1
smsMsg1:SimpleMessageServiceMessage@1
smsMsg1.getId():1
user.getSimpleMessageServiceMessages().contains(smsMsg1):false
user.getSimpleMessageServiceMessages().remove(smsMsg1):false
after user.getSimpleMessageServiceMessages().size():1
-------------------------------------

smsMsg1 is taken out from user.getSimpleMessageServiceMessages().toArray()[0]

the same object is used in the call to :user.getSimpleMessageServiceMessages().remove(smsMsg1) and also
user.getSimpleMessageServiceMessages().contains(smsMsg1), both of which gave me FALSE!!!


The underlying implementation of the set is java.util.Set

I dont have this problem with other normal parent to child r/s in hibernate. The only difference is that i am using discriminator classes as the child which in this case is SimpleMessageServiceMessage

The hibernate file goes as below:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping >


<class name="MobileMessage" table="MOBILE_MESSAGE">
<id name="id" type="long" unsaved-value="0">
<generator class="native"/>
</id>
<discriminator column="msg_type" type="string"/>

<property name="senderMobileNumber" column="sender_mobile_num" not-null="true" type="string" />
<property name="receipientMobileNumber" column="receipient_mobile_num" not-null="true" type="string"/>
<many-to-one name="user" class="reynolds.sms.hibernate.User" column="user_id" not-null="true"/>

<subclass name="SimpleMessageServiceMessage" discriminator-value="SMS">
<property name="message" column="text_msg" type="string"/>
</subclass>

<subclass name="MultimediaMessage" discriminator-value="MMS">
<property name="message" column="text_msg" type="string"/>
<property name="picture" column="picture" type="string"/>
</subclass>
</class>
</hibernate-mapping>




The parent side of the relationship in the User.hbm.xml file is :

<set name="simpleMessageServiceMessages" cascade="all" lazy="true" inverse="true">
<key column="user_id"/>
<one-to-many class="SimpleMessageServiceMessage"/>
</set>


obviously, since i cant seem to delete that particular object from User, and when i try to sess.delete(smsMsg1); i get a hibernate error.
The only way i can remove smsMsg1 is to call user.getSimpleMessageServiceMessage().clear(). Thats the only way. Has anyone faced such a frustrating and illogical code problem?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 23, 2004 7:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
most likely your equals/hashCode implementation is broken.


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.