@@ -166,7 +166,7 @@ private static Element dereference(AccessType defaultAccessType, Element symbol,
166
166
private Type propertyType (Element member , String entityName , String path , AccessType defaultAccessType ) {
167
167
final TypeMirror memberType = memberType (member );
168
168
if (isEmbeddedProperty (member )) {
169
- return component . make ( asElement ( memberType ), entityName , path , defaultAccessType , this );
169
+ return componentType ( entityName , path , defaultAccessType , memberType );
170
170
}
171
171
else if (isToOneAssociation (member )) {
172
172
return new ManyToOneType (getTypeConfiguration (), getToOneTargetEntity (member ));
@@ -186,6 +186,10 @@ else if (isEnumProperty(member)) {
186
186
}
187
187
}
188
188
189
+ private Component componentType (String entityName , String path , AccessType defaultAccessType , TypeMirror memberType ) {
190
+ return component .make ( asElement ( memberType ), entityName , path , defaultAccessType , this );
191
+ }
192
+
189
193
@ SuppressWarnings ({"rawtypes" , "unchecked" })
190
194
private static BasicType <?> enumType (Element member , TypeMirror memberType ) {
191
195
final Class <Enum > enumClass = Enum .class ; // because we can't load the real enum class!
@@ -414,6 +418,12 @@ public String identifierPropertyName() {
414
418
415
419
@ Override
416
420
public Type identifierType () {
421
+ if (hasAnnotation ( type , "IdClass" )) {
422
+ final TypeMirror annotationMember = (TypeMirror )getAnnotationMember ( getAnnotation ( type , "IdClass" ), "value" );
423
+ if (annotationMember != null ) {
424
+ return factory .componentType ( getEntityName (), EntityIdentifierMapping .ID_ROLE_NAME , defaultAccessType , annotationMember );
425
+ }
426
+ }
417
427
for (Element element : type .getEnclosedElements ()) {
418
428
if ( hasAnnotation (element , "Id" )|| hasAnnotation (element , "EmbeddedId" ) ) {
419
429
return factory .propertyType (element , getEntityName (), EntityIdentifierMapping .ID_ROLE_NAME , defaultAccessType );
@@ -490,7 +500,8 @@ String qualifyName(String jpaEntityName) {
490
500
boolean isAttributeDefined (String entityName , String fieldName ) {
491
501
final TypeElement entityClass = findEntityClass (entityName );
492
502
return entityClass != null
493
- && findPropertyByPath (entityClass , fieldName , getDefaultAccessType (entityClass )) != null ;
503
+ && (findPropertyByPath (entityClass , fieldName , getDefaultAccessType (entityClass )) != null
504
+ || "id" .equals ( fieldName ) && hasAnnotation ( entityClass , "IdClass" ));
494
505
}
495
506
496
507
public TypeElement findEntityClass (String entityName ) {
0 commit comments