-->
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: hibernate does not manage mapping configuration dependency??
PostPosted: Wed Jun 08, 2005 5:34 pm 
Beginner
Beginner

Joined: Sun May 02, 2004 8:04 am
Posts: 36
Hi,

We're using Hibernate 2 and normally would load in all the mapping files like so:
Code:
cfg = new Configuration();
cfg.setProperties(hibernateProperties);

for (Iterator filenames = filenameList.iterator(); filenames.hasNext();) {
    String filename = (String) filenames.next();
    if (filename.endsWith(".hbm.xml")) {
      // Get filename of file or directory
     cfg.addFile(mappingPath + File.separator + filename);
}


It seems this works fine on most platforms but on Fedora Linux for some reason, we get errors when one mapping class extends another mapping class but the base class located in filename B.hbm.xml comes after the subclass in A.hbm.xml. It seems that it all works fine if we make sure to alphabetize the mapping files before loading them in e.g.

Code:
List filenameList = Arrays.asList(children);
// Ensure that this list is sorted alphabetically
Collections.sort(filenameList);

but this seems like a bit of hack (since now it will fail in the reverse situation). It seems to me Hibernate should somehow take care of resolving the dependency tree behind the scenes...

Quote:
[dbtask] 593 [main] (DBTask.java:197) INFO org.gridlab.gridsphere.core.persistence.hibernate.DBTask - Using mapping directory: /usr/local/tomcat/webapps/gridportlets/WEB-INF/persistence
[dbtask] 2618 [main] (Configuration.java:256) ERROR net.sf.hibernate.cfg.Configuration - Could not compile the mapping document
[dbtask] net.sf.hibernate.MappingException: Cannot extend unmapped class: org.gridlab.gridsphere.services.resource.impl.BaseResource
[dbtask] at net.sf.hibernate.cfg.Binder.getSuperclass(Binder.java:1338)
[dbtask] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1263)
[dbtask] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:253)
[dbtask] at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:175)
[dbtask] at org.gridlab.gridsphere.core.persistence.hibernate.DBTask.getDBConfiguration(DBTask.java:202)
[dbtask] at org.gridlab.gridsphere.core.persistence.hibernate.DBTask.execute(DBTask.java:240)
[dbtask] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)


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.