rmswalsh wrote:
Hi,
I am stuck on this also. What is a valid workaround for this.
thanks,
Richie.
You can try using the overload for the AddAssembly method where you state that it should not use the orderer. That will cause NHibernate to skip this section of the code. I did not think that would work for me, so I changed the NHibernate source code and rebuilt it. I changed the code in the AssemblyHbmOrderer:OrderedHbmFiles(ISet) method to:
Code:
// Make sure joined-subclass mappings are loaded after base class
ArrayList sortedList = new ArrayList();
ISet processedClassNames = new HashedSet();
ArrayList processedInThisIteration = new ArrayList();
while (true)
{
foreach (ClassEntry ce in unorderedClasses)
{
if (ce.FullExtends == null || processedClassNames.Contains(ce.FullExtends))
{
// This class extends nothing, or is derived from one of the classes that were already processed.
// Append it to the list since it's safe to process now.
sortedList.Add(ce);
processedClassNames.Add(ce.FullClassName);
processedInThisIteration.Add(ce);
}
}
unorderedClasses.RemoveAll(processedInThisIteration);
if (processedInThisIteration.Count == 0)
{
if (!unorderedClasses.IsEmpty)
{
//throw new MappingException(FormatExceptionMessage(unorderedClasses));
//If we couldn't find a matching base class we'll just load them last.
//hopefully the class was loaded with a prior assembly.
sortedList.AddRange(unorderedClasses);
}
break;
}
processedInThisIteration.Clear();
}
// now that we know the order the classes should be loaded - order the
// hbm.xml files those classes are contained in.
StringCollection loadedFiles = new StringCollection();
foreach (ClassEntry ce in sortedList)
{
// Check if this file already loaded (this can happen if
// we have mappings for multiple classes in one file).
if (loadedFiles.Contains(ce.FileName) == false)
{
loadedFiles.Add(ce.FileName);
}
}
return loadedFiles;
Note the key section where I commented out the throw new MappingException. Instead of saying I couldn't find a class to extend I just assume I could and load those files last.
This is actually what NHibernate 1.0.x used to do, and why I decided it was safe to do it. Now if these classes really don't exist there will be problems, but we can verify that on our own for now.
We plan to use this build until 1.2.1 comes out, at which time we'll replace our build with the standard release.