-->
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: contained elements not loaded
PostPosted: Thu Mar 22, 2007 8:52 am 
Newbie

Joined: Fri Jul 21, 2006 6:27 am
Posts: 10
hi all!

somehow, hibernate doesnt load the contained objects of the requested object.
im loading a modulefolder, but the contained module is not loaded along with it.(see mapping)
why is that?
important parts of mapping below, full mapping file available here:
http://donhofer.net/mirror/hibernate/hibernate.hbm.xml

Ta, chris

Hibernate version:
3
Mapping documents:
Code:
<union-subclass entity-name="ModuleFolder" abstract="false" lazy="false" extends="LearningObject" table="`MODULEFOLDER`">
      <meta attribute="eclassName">ModuleFolder</meta>
      <meta attribute="epackage">lobj.ecore</meta>
      <many-to-one name="folderMeta" entity-name="FolderMeta" cascade="delete,merge,persist,save-update,lock,refresh" lazy="false" insert="true" update="true" not-null="false">
         <column not-null="false" unique="false" name="`FOLDERMETA_ID`"/>
      </many-to-one>
      <bag name="moduleFolder" lazy="true" cascade="delete,merge,persist,save-update,lock,refresh">
         <key update="true">
            <column name="`MODULEFOLDER_ID`" not-null="false" unique="false"/>
         </key>
         <one-to-many entity-name="ModuleFolder"/>
      </bag>
      <bag name="module" lazy="false" cascade="delete,merge,persist,save-update,lock,refresh">
         <key update="true">
            <column name="`MODULEFOLDER_ID`" not-null="false" unique="false"/>
         </key>
         <one-to-many entity-name="Module"/>
      </bag>
      <many-to-one name="accessControl" entity-name="AccessControl" cascade="delete,merge,persist,save-update,lock,refresh" lazy="false" insert="true" update="true" not-null="false">
         <column not-null="false" unique="false" name="`ACCESSCONTROL_ID`"/>
      </many-to-one>
   </union-subclass>

Code between sessionFactory.openSession() and session.close():
Code:
session = dataStore.getSessionFactory().openSession();
      Transaction tx = session.getTransaction();

                ResourceSet resourceSet = new ResourceSetImpl();
      // Register the appropriate resource factory to handle all file extentions.

      resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put
      ("lobj",
       new LobjResourceFactoryImpl());
      
      // Register the package to ensure it is available during loading.
      //
      resourceSet.getPackageRegistry().put
            (LobjPackage.eNS_URI,
             LobjPackage.eINSTANCE);
                //create resource
      Resource rs = resourceSet.createResource(URI.createFileURI("dummy.lobj"));
      
      // start transaction
      tx.begin();
      
      // query for object by ID
      Query qry = session.createQuery("from "+eclassname+" where id='"+id+"'");
      List list = qry.list();

for(Iterator iter = list.iterator(); iter.hasNext();){
         EObject element = (EObject) iter.next();
         rs.getContents().add(element);
         for (Iterator featureIterator =
              EcoreUtil.getAllContents(element, true);
            featureIterator.hasNext(); ) {
             EObject eObject = (EObject)featureIterator.next();
             rs.getContents().add(eObject);
         }
      }
//serialize resource
String myObject = resourceToString(rs, encoding);
tx.commit();
session.close();
return myObject;

Name and version of the database you are using:
mysql 4.1.1


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.