I am not clear if Hibernate supports mixed inheritence stratgies. I was looking at the source code I checked out class AnnotationBinder
. There is see the following method that gets called when resolving the “inheritence state” for each of the entity class:
private static void logMixedInheritance(XClass clazz, InheritanceState superclassState, InheritanceState state) {
if ( state.getType() != null && superclassState.getType() != null ) {
final boolean nonDefault = InheritanceType.SINGLE_TABLE != state.getType();
final boolean mixingStrategy = state.getType() != superclassState.getType();
if ( nonDefault && mixingStrategy ) {
throw new AnnotationException( "Entity '" + clazz.getName()
+ "' may not override the inheritance mapping strategy '" + superclassState.getType()
+ "' of its hierarchy"
+ "' (each entity hierarchy has a single inheritance mapping strategy)" );
}
}
}
}
Based on the exception message, it seems like Hibernate does not support mixed inheritance strategies.
However, if that’s the case, shouldn’t the exception be thrown if just mixingStrategy
is yields true
? I am not sure if I understand the relevance of nonDefault here.
Is this a bug or am I misunderstanding something?