Source:
<code>public void visit(PropertyExpression expression) { String property = expression.getProperty(); if (currentPosition.getCurrentType() instanceof BasicType<?>) { throw new IllegalArgumentException("Can't access property '" + property + "' on basic type '" + JpaMetamodelUtils.getTypeName(currentPosition.getCurrentType()) + "'. Did you forget to add the embeddable type to your persistence.xml?"); } Attribute<?, ?> attribute = JpaMetamodelUtils.getAttribute((ManagedType<?>) currentPosition.getCurrentType(), property); if (attribute == null) { throw new IllegalArgumentException("Attribute '" + property + "' not found on type '" + JpaMetamodelUtils.getTypeName(currentPosition.getCurrentType()) + "'"); } currentPosition.setAttribute(attribute); Type<?> type = getType(currentPosition.getCurrentType(), attribute); Type<?> valueType = null; Type<?> keyType = null; if (attribute instanceof PluralAttribute<?, ?, ?>) { Class<?> javaType = type.getJavaType(); Class<?>[] typeArguments; if (javaType == null) { typeArguments = EMPTY; } else { if (attribute.getJavaMember() instanceof Field) { typeArguments = ReflectionUtils.getResolvedFieldTypeArguments(currentPosition.getCurrentClass(), (Field) attribute.getJavaMember()); } else if (attribute.getJavaMember() instanceof Method) { typeArguments = ReflectionUtils.getResolvedMethodReturnTypeArguments(currentPosition.getCurrentClass(), (Method) attribute.getJavaMember()); } else { typeArguments = EMPTY; } } if (typeArguments.length == 0) { if (attribute instanceof MapAttribute<?, ?, ?>) { keyType = ((MapAttribute<?, ?, ?>) attribute).getKeyType(); } valueType = ((PluralAttribute<?, ?, ?>) attribute).getElementType(); } else { valueType = metamodel.type(typeArguments[typeArguments.length - 1]); if (typeArguments.length > 1) { keyType = metamodel.type(typeArguments[0]); } } } else if (attribute instanceof SingularAttribute<?,?>) { <START> valueType = type = ((SingularAttribute) attribute).getType(); <END> } else { valueType = type; } currentPosition.setCurrentType(type); currentPosition.setValueType(valueType); currentPosition.setKeyType(keyType); }</code><technical_language>do this is necessary? If is some of type variables, IMO this break this. type in case of type variables concrete type</technical_language>

Target:
public void visit(PropertyExpression expression) { String property = expression.getProperty(); if (currentPosition.getCurrentType() instanceof BasicType<?>) { throw new IllegalArgumentException("Can't access property '" + property + "' on basic type '" + JpaMetamodelUtils.getTypeName(currentPosition.getCurrentType()) + "'. Did you forget to add the embeddable type to your persistence.xml?"); } Attribute<?, ?> attribute = JpaMetamodelUtils.getAttribute((ManagedType<?>) currentPosition.getCurrentType(), property); if (attribute == null) { throw new IllegalArgumentException("Attribute '" + property + "' not found on type '" + JpaMetamodelUtils.getTypeName(currentPosition.getCurrentType()) + "'"); } currentPosition.setAttribute(attribute); Type<?> type = getType(currentPosition.getCurrentType(), attribute); Type<?> valueType = null; Type<?> keyType = null; if (attribute instanceof PluralAttribute<?, ?, ?>) { Class<?> javaType = type.getJavaType(); Class<?>[] typeArguments; if (javaType == null) { typeArguments = EMPTY; } else { if (attribute.getJavaMember() instanceof Field) { typeArguments = ReflectionUtils.getResolvedFieldTypeArguments(currentPosition.getCurrentClass(), (Field) attribute.getJavaMember()); } else if (attribute.getJavaMember() instanceof Method) { typeArguments = ReflectionUtils.getResolvedMethodReturnTypeArguments(currentPosition.getCurrentClass(), (Method) attribute.getJavaMember()); } else { typeArguments = EMPTY; } } if (typeArguments.length == 0) { if (attribute instanceof MapAttribute<?, ?, ?>) { keyType = ((MapAttribute<?, ?, ?>) attribute).getKeyType(); } valueType = ((PluralAttribute<?, ?, ?>) attribute).getElementType(); } else { valueType = metamodel.type(typeArguments[typeArguments.length - 1]); if (typeArguments.length > 1) { keyType = metamodel.type(typeArguments[0]); } } } else { valueType = type; } currentPosition.setCurrentType(type); currentPosition.setValueType(valueType); currentPosition.setKeyType(keyType); }