-->
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.  [ 3 posts ] 
Author Message
 Post subject: Cascade malfunction: hibernate assigns weird id's
PostPosted: Fri Aug 06, 2004 7:23 am 
Newbie

Joined: Tue Jul 20, 2004 7:03 am
Posts: 19
Location: Spain
Hi all.

This post is long.

Hibernate assigns wrong id's to a cascaded object, so it could never be loaded correctly.

The mappings are here:


Code:
<!-- CONTENT -->
   <class
      dynamic-insert="false"
      dynamic-update="false"
      name="com.zzz.contentManagement.model.Content"
   >
      <id
         name="id"
         type="java.lang.Long"
         unsaved-value="null"
      >
         <generator class="native" />
      </id>
        <property name="created" type="java.util.Date" not-null="true"/>
        <property name="author" type="java.lang.String"/>

      <!-- relations -->
      <set name="relations">
         <key column="id"/>
         <one-to-many class="com.zzz.contentManagement.model.Relation"/>
      </set>

      <!-- translations -->
      <map name="translations" cascade="all">
         <key/>
         <!-- indexed by language id (see Locale) -->
         <index column="localeId" type="string"/>
         <one-to-many class="com.zzz.contentManagement.model.Translation"/>
      </map>


<!-- TRANSLATION -->

   <class
      dynamic-insert="false"
      dynamic-update="false"
      name="com.zzz.contentManagement.model.Translation"
   >
      <id
         name="id"
         type="java.lang.Long"
         unsaved-value="null"
      >
         <generator class="native" />
      </id>
      <map name="KeyValues" table="KeyValues" cascade="all">
         <key foreign-key="id"/>
         <index column="translationKey" type="string"/>
         <element column="value" type="string"/>
      </map>
   </class>





The KeyValues table is the problem, the data there does not match with the id in Translation table !!!

The test code is here:

Code:
      Resort resort = new Resort();
      Translation trans_EN = new Translation();
      trans_EN.getKeyValues().put("name_short", "Los Cristianos");
      resort.addToTranslations("EN",trans_EN);
      com.zzz.util.log.LogUtil.getDebugLogger().debug("Saving "+resort);
      Long key = itfModel.saveNewContent(resort);
      
      Content content = itfModel.getDraftContent(key);
      com.zzz.util.log.LogUtil.getDebugLogger().debug("EN = "+content.getMessage("description_short","EN"));


This shows null, the key inserted into the DB is 1, and the correct key should be 2.

This is really frustrating, so i'm thinking about suicide, as told in this procedure http://www.msu.edu/~couilla3/ninja/seppuku.htm
Please, don't let me do it :)

Hibernate version = hibernate-2.1.4
Java = 1.4.2


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 06, 2004 7:25 am 
Newbie

Joined: Tue Jul 20, 2004 7:03 am
Posts: 19
Location: Spain
Ah!
MySQL DB v.4018


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 08, 2004 2:26 pm 
Beginner
Beginner

Joined: Mon Aug 02, 2004 1:08 pm
Posts: 42
Post more code, turn on logging.

When asking questions, give at least:
# the Hibernate version
# your mapping documents
# the Java code between sessionFactory.openSession() and session.close()
# the full stack trace of any exception that occurs
# the name and version of the database you are using
# a debug level Hibernate log excerpt is also appreciated


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