HHH-5125 Raise proper exception when @Entity and @MappedSuperclass are present on the same class

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@19241 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Emmanuel Bernard 2010-04-16 10:11:32 +00:00
parent 5da56b7881
commit 422ecc653a
1 changed files with 7 additions and 0 deletions

View File

@ -504,6 +504,13 @@ public final class AnnotationBinder {
public static void bindClass( public static void bindClass(
XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, ExtendedMappings mappings XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, ExtendedMappings mappings
) throws MappingException { ) throws MappingException {
//@Entity and @MappedSuperclass on the same class leads to a NPE down the road
if ( clazzToProcess.isAnnotationPresent( Entity.class )
&& clazzToProcess.isAnnotationPresent( MappedSuperclass.class ) ) {
throw new AnnotationException( "An entity cannot be annotated with both @Entity and @MappedSuperclass: "
+ clazzToProcess.getName() );
}
//TODO: be more strict with secondarytable allowance (not for ids, not for secondary table join columns etc) //TODO: be more strict with secondarytable allowance (not for ids, not for secondary table join columns etc)
InheritanceState inheritanceState = inheritanceStatePerClass.get( clazzToProcess ); InheritanceState inheritanceState = inheritanceStatePerClass.get( clazzToProcess );
AnnotatedClassType classType = mappings.getClassType( clazzToProcess ); AnnotatedClassType classType = mappings.getClassType( clazzToProcess );