-->
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: Getting odd behavior with PersistentSet
PostPosted: Tue Oct 17, 2006 4:37 pm 
Newbie

Joined: Fri Feb 25, 2005 4:11 pm
Posts: 4
Location: Fayetteville, GA
Hibernate version:3.1

Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Oct 4, 2006 1:09:02 PM by Hibernate Tools 3.1.0.beta4 -->
<hibernate-mapping default-cascade="save-update">
    <class name="business.domain.UserFo" table="USER_FO">
        <id name="id" type="java.lang.Long" unsaved-value="null">
            <meta attribute="use-in-tostring">true</meta>
            <meta attribute="use-in-equals">true</meta>
            <column name="ID" precision="15" scale="0" />
            <generator class="sequence">
                <param name="sequence">USER_FO_ID</param>
            </generator>
        </id>
        <version name="version" type="java.lang.Long">
            <column name="VERSION" precision="15" scale="0" not-null="true" />
        </version>
        <many-to-one name="usersByInsertUserId" class="business.domain.User" fetch="select" cascade="none">
            <column name="INSERT_USER_ID" precision="15" scale="0" not-null="true" />
        </many-to-one>
        <many-to-one name="usersByLastUpdateUserId" class="business.domain.User" fetch="select" cascade="none">
            <column name="LAST_UPDATE_USER_ID" precision="15" scale="0" not-null="true" />
        </many-to-one>
        <many-to-one name="usersByUsersId" class="business.domain.User" fetch="select">
            <column name="USERS_ID" precision="15" scale="0" not-null="true" />
        </many-to-one>
        <many-to-one name="hudOffice" class="business.domain.HudOffice" fetch="select" cascade="none">
        <!--Lana many-to-one name="hudOffice" class="business.domain.HudOffice" fetch="select"-->
            <column name="HUD_OFFICE_ID" precision="15" scale="0" not-null="true" />
        </many-to-one>
        <many-to-one name="profileStatus" class="business.domain.ProfileStatus" fetch="select" cascade="none">
        <!--Lana many-to-one name="profileStatus" class="business.domain.ProfileStatus" fetch="select"-->
            <column name="PROFILE_STATUS_ID" precision="15" scale="0" not-null="true" />
        </many-to-one>
        <property name="statusUpdateUserId" type="java.lang.Long">
            <meta attribute="use-in-tostring">true</meta>
            <meta attribute="use-in-equals">true</meta>
            <column name="STATUS_UPDATE_USER_ID" precision="15" scale="0" not-null="true" />
        </property>
        <property name="statusUpdateTimestamp" type="timestamp">
            <meta attribute="use-in-tostring">true</meta>
            <meta attribute="use-in-equals">true</meta>
            <column name="STATUS_UPDATE_TIMESTAMP" length="7" not-null="true" />
        </property>
        <property name="insertTimestamp" type="timestamp">
            <meta attribute="use-in-tostring">true</meta>
            <column name="INSERT_TIMESTAMP" length="7" not-null="true" />
        </property>
        <property name="lastUpdateTimestamp" type="timestamp">
            <meta attribute="use-in-tostring">true</meta>
            <column name="LAST_UPDATE_TIMESTAMP" length="7" not-null="true" />
        </property>
        <set name="foProfileStatusHists" inverse="true">
            <key>
                <column name="FO_USER_ID" precision="15" scale="0" not-null="true" />
            </key>
            <one-to-many class="business.domain.FoProfileStatusHist" />
        </set>
        <set name="profileFos" inverse="true" cascade="save-update,delete-orphan">
        <!--Lana set name="profileFos" inverse="true"-->
            <key>
                <column name="USER_FO_ID" precision="15" scale="0" not-null="true" />
            </key>
            <one-to-many class="business.domain.ProfileFo" />
        </set>
    </class>
</hibernate-mapping>



Name and version of the database you are using: Oracle 10g

The weird problem I have is that when I have a set of entities (profileFos in the mapping above) in hibernate and attempt to delete one no deletion occurs. I have code where I take the same domain objects and perform the same operations using a standard java.util.HashSet and it works properly. I was using the HashSet to verify my equals and hashcode functions are correct.

In addition if I have 5 of an object in a PersistentSet and then add the exact same 5 objects (equals returns true, and the hashcodes are identical) I seem to get 10 objects in the set. Which doesn't happen with the HashSet class.

Anyone seen this before?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 10:29 pm 
Newbie

Joined: Tue Nov 07, 2006 5:06 pm
Posts: 13
I remember something very similar to that driving me crazy a while back, but can't recall what I did to resolve it... I don't think I ever figured out exactly what was wrong, just did some work-around.


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.