-->
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: Wrong entity attached in one-to-one relation.
PostPosted: Mon May 17, 2010 6:01 am 
Newbie

Joined: Mon May 17, 2010 5:44 am
Posts: 1
Hello,

I have this awkward problem that randomly wrong entity is attached to the entity. Here are the somewhat changed (names) mapping files:

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">
<hibernate-mapping default-access="field">

  <class name="com.coolwebsite.Plan" schema="PLAN" table="PLAN">
    <id name="id" column="ID" unsaved-value="0">
      <generator class="sequence">
        <param name="sequence">PLAN.PLAN_ID_SEQ</param>
      </generator>
    </id>

    <many-to-one name="party" column="PARTY_ID" class="com.coolwebsite.Party" cascade="save-update,persist"/>

    <set name="relatedParties" schema="PLAN" table="RELATED_PARTIES" sort="natural" cascade="all,delete-orphan" fetch="subselect">
      <key column="ID"/>
      <many-to-many column="PARTY_ID" class="com.coolwebsite.Party"/>
    </set>

    [...]

  </class>

</hibernate-mapping>


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

  <class name="com.coolwebsite.Party" schema="PLAN" table="PARTY" batch-size="20">
    <id name="id" column="PARTY_ID" unsaved-value="0">
      <generator
        class="sequence">
        <param name="sequence">PLAN.PARTY_ID_SEQ</param>
      </generator>
    </id>

    [...]
  </class>

</hibernate-mapping>



Sometimes wrong Party is attached to Plan.party. These are used in a web application and after refresh it corrects itself. I haven't found a concrete pattern of when this bug appears, it only appears on some Plans.

Using Hibernate 3.3.1.GA with Oracle DBMS.

Anyone has had these kind of problems? Or which further information I could provide?

Thanks.


Top
 Profile  
 
 Post subject: Re: Wrong entity attached in one-to-one relation.
PostPosted: Mon May 17, 2010 11:14 am 
Regular
Regular

Joined: Tue May 11, 2010 5:50 pm
Posts: 54
Location: Norman, Ok, U.S.A
why do you have a many-to-many in your set? Try setting that into relatedParties own mapping file


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.