On building a session factory the HbmBinder.bindRoot() delays subclass entity mapping creation, if one the referenced superclasses has not been loaded, yet.
If one mapping file contains mappings for multiple subclasses, which reference still not loaded superclasses, then there occurs a bug because of the way the queuing works for delayed loading. For each missing superclass there is created one queue entry containing ALL the entities of the mapping file.
Consider the following example:
There are referenced two superclasses RootClass1 and RootClass2. If they both are not loaded yet the created queue entries are:
Later on, when the queued entries are iterated through, the subclasses are going to be mapped twice. This leads to a DuplicateMappingException.
Workaround 1: define mapping files which contain at most one subclass mapping.
Workaround 2: assure that superclass mappings are always loaded before subclass mappings.
I think this a bug, as generally it is allowed to define more than one subclass mapping per mapping file. The order in which mapping files are loaded is free, as the HbmBinder contains a treatment for this case (as mentioned in this bug ticket).
Test case attached.