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)