|
95 | 95 | import static org.hibernate.processor.util.TypeUtils.getAnnotationMirror; |
96 | 96 | import static org.hibernate.processor.util.TypeUtils.getAnnotationValue; |
97 | 97 | import static org.hibernate.processor.util.TypeUtils.getGeneratedClassFullyQualifiedName; |
| 98 | +import static org.hibernate.processor.util.TypeUtils.getInheritedAnnotationMirror; |
98 | 99 | import static org.hibernate.processor.util.TypeUtils.hasAnnotation; |
99 | 100 | import static org.hibernate.processor.util.TypeUtils.implementsInterface; |
100 | 101 | import static org.hibernate.processor.util.TypeUtils.primitiveClassMatchesKind; |
@@ -701,9 +702,20 @@ else if ( idType != null && finalPrimaryEntity != null ) { |
701 | 702 | } |
702 | 703 |
|
703 | 704 | private @Nullable TypeMirror findIdType() { |
704 | | - Element idMember = findIdMember(); |
705 | 705 | TypeElement primaryEntityForTest = primaryEntity; |
706 | | - if ( idMember != null && primaryEntityForTest != null ) { |
| 706 | + if ( primaryEntityForTest == null ) { |
| 707 | + return null; |
| 708 | + } |
| 709 | + AnnotationMirror idClass = getInheritedAnnotationMirror( this.context.getElementUtils(), primaryEntityForTest, ID_CLASS ); |
| 710 | + if ( idClass != null ) { |
| 711 | + AnnotationValue value = getAnnotationValue(idClass, "value" ); |
| 712 | + // I don't think this can have a null value |
| 713 | + if ( value != null ) { |
| 714 | + return (TypeMirror) value.getValue(); |
| 715 | + } |
| 716 | + } |
| 717 | + Element idMember = findIdMember(); |
| 718 | + if ( idMember != null ) { |
707 | 719 | TypeMirror typedIdMember = this.context.getTypeUtils().asMemberOf((DeclaredType) primaryEntityForTest.asType(), idMember); |
708 | 720 | return switch(typedIdMember.getKind()) { |
709 | 721 | case ARRAY, DECLARED, BOOLEAN, BYTE, CHAR, SHORT, INT, LONG, FLOAT, DOUBLE -> typedIdMember; |
|
0 commit comments