-->
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.  [ 1 post ] 
Author Message
 Post subject: Automatic Population of Collection Key
PostPosted: Wed Jun 08, 2005 11:45 am 
Newbie

Joined: Wed Jun 08, 2005 11:26 am
Posts: 1
Hi

I'm having a problem understanding what is happening when I save an object with collections. I've had a good dig around the documentation and the FAQs but think I'm perhaps just making the wrong assumptions.

If you look at the mapping files below, when I save a LearningObjectVO (subclass of PackagePartVO) then everything is saved correctly in the database, good start! However when I then view the contents of the LearningObjectVO I was expecting the learningObjectId field on the MetadataValueVO to be populated with the id from the LearningObjectVO but it isn't. If I get the LearningObjectVO out of the database again then everything is fine and dandy. My question is should I have to do this, I wouldn't have expected to have to select the object again once I'd carried out the save.

Details of the version, mapping files etc ...

Hibernate version: 2.1.6

Mapping documents:
Code:
<class name="com.intrallect.intralibrary.vo.MetadataValueVO" table="metadata_values">
      <id name="id" type="int" column="id" unsaved-value="0">
         <generator class="identity" />
      </id>
      <property name="value"/>
      <property name="learningObjectId" column="lnob_id"/>
      <property name="languageId" column="lgst_id"/>
      <property name="xpath" column="xpath"/>
      <property name="sourceId" column="source_id"/>
      <many-to-one name="metadataEntry" class="com.intrallect.intralibrary.vo.MetadataEntryVO" column="metadata_id" />
   </class>

Code:
<class name="com.intrallect.intralibrary.vo.PackagePartVO" table="package_part" discriminator-value="PACKAGE_PART">
      <id name="id" type="int" column="id" unsaved-value="0">
         <generator class="identity" />
      </id>

      <discriminator column="hibernate_discriminator" type="string"/>

      <property name="packagePartType" column="package_part_type" not-null="true"/>
      <property name="parentId" column="parent_id"/>
      <property name="lastUpdated" column="last_updated"/>
      <property name="fileName" column="file_name"/>
      <property name="manifestVersion" column="version"/>
      <property name="manifestId" column="manifest_id"/>
      <property name="type" column="type" not-null="true"/>
      <property name="location" column="location"/>
      <map name="metadataMap" cascade="all-delete-orphan">
         <key column="lnob_id"/>
         <index column="xpath" type="string"/>
         <one-to-many class="com.intrallect.intralibrary.vo.MetadataValueVO" />
      </map>

      <!-- LearningObjectVO -->
         <subclass name="com.intrallect.intralibrary.vo.LearningObjectVO" discriminator-value="LEARNING_OBJECT">
            <bag name="organizations" cascade="all">
               <key column="lnob_id"/>
               <one-to-many class="com.intrallect.intralibrary.vo.OrganizationNodeVO" />
            </bag>
            <bag name="learningItems" cascade="all">
               <key column="lnob_id"/>
               <one-to-many class="com.intrallect.intralibrary.vo.LearningItemVO" />
            </bag>
            <bag name="resources" cascade="all">
               <key column="lnob_id"/>
               <one-to-many class="com.intrallect.intralibrary.vo.ResourceVO" />
            </bag>
            <bag name="childLearningObjects" cascade="all-delete-orphan" >
               <key column="parent_id"/>
               <one-to-many class="com.intrallect.intralibrary.vo.LearningObjectVO" />
            </bag>
            <one-to-one name="learningObjectInfo" class="com.intrallect.intralibrary.vo.LearningObjectInfoVO" property-ref="learningObject" cascade="all"/>
         </subclass>
      <!-- LearningObjectVO -->
   </class>

Code between sessionFactory.openSession() and session.close():
Code:
      try
      {
         beginTransaction();

         currentSession().saveOrUpdate( hibernateVO );

         commitTransaction();
      }
      catch ( HibernateException e )
      {
         rollbackTransaction();
         throw new IntegrationException( e );
      }
      finally
      {
         closeSession();
      }


Full stack trace of any exception that occurs: No Exception

Name and version of the database you are using: MySQL 4.0.20


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.