@@ -166,7 +166,7 @@ private static Element dereference(AccessType defaultAccessType, Element symbol,
166166 private Type propertyType (Element member , String entityName , String path , AccessType defaultAccessType ) {
167167 final TypeMirror memberType = memberType (member );
168168 if (isEmbeddedProperty (member )) {
169- return component . make ( asElement ( memberType ), entityName , path , defaultAccessType , this );
169+ return componentType ( entityName , path , defaultAccessType , memberType );
170170 }
171171 else if (isToOneAssociation (member )) {
172172 return new ManyToOneType (getTypeConfiguration (), getToOneTargetEntity (member ));
@@ -186,6 +186,10 @@ else if (isEnumProperty(member)) {
186186 }
187187 }
188188
189+ private Component componentType (String entityName , String path , AccessType defaultAccessType , TypeMirror memberType ) {
190+ return component .make ( asElement ( memberType ), entityName , path , defaultAccessType , this );
191+ }
192+
189193 @ SuppressWarnings ({"rawtypes" , "unchecked" })
190194 private static BasicType <?> enumType (Element member , TypeMirror memberType ) {
191195 final Class <Enum > enumClass = Enum .class ; // because we can't load the real enum class!
@@ -414,6 +418,12 @@ public String identifierPropertyName() {
414418
415419 @ Override
416420 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+ }
417427 for (Element element : type .getEnclosedElements ()) {
418428 if ( hasAnnotation (element , "Id" )|| hasAnnotation (element , "EmbeddedId" ) ) {
419429 return factory .propertyType (element , getEntityName (), EntityIdentifierMapping .ID_ROLE_NAME , defaultAccessType );
@@ -490,7 +500,8 @@ String qualifyName(String jpaEntityName) {
490500 boolean isAttributeDefined (String entityName , String fieldName ) {
491501 final TypeElement entityClass = findEntityClass (entityName );
492502 return entityClass != null
493- && findPropertyByPath (entityClass , fieldName , getDefaultAccessType (entityClass )) != null ;
503+ && (findPropertyByPath (entityClass , fieldName , getDefaultAccessType (entityClass )) != null
504+ || "id" .equals ( fieldName ) && hasAnnotation ( entityClass , "IdClass" ));
494505 }
495506
496507 public TypeElement findEntityClass (String entityName ) {
0 commit comments