Author: epbernard
Date: 2010-04-16 06:11:32 -0400 (Fri, 16 Apr 2010)
New Revision: 19241
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java
Log:
HHH-5125 Raise proper exception when @Entity and @MappedSuperclass are present on the same
class
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
---
core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java 2010-04-15
09:37:36 UTC (rev 19240)
+++
core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java 2010-04-16
10:11:32 UTC (rev 19241)
@@ -504,6 +504,13 @@
public static void bindClass(
XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass,
ExtendedMappings mappings
) 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)
InheritanceState inheritanceState = inheritanceStatePerClass.get( clazzToProcess );
AnnotatedClassType classType = mappings.getClassType( clazzToProcess );
Show replies by date