Accounting for attribute metaproperty in a JPQL query

There was a problem with taking into account the metaproperty in a JPQL query to get an entity with a given metaproperty value.

The class has the following metaproperty:

@MetaProperty
public String getProperName() {
    return String.format("%s%s%s",
        (getCenName() == null) ? "" : getCenName().getValue(),
        (getCenLastName() == null) ? "" : getCenLastName().getSubject(),
        (getApendix() == null) ? "" : getApendix());
}

When I try to execute the following query:

select u.description.getProperName from User u

I get an error:

Exception Description: Problem compiling [select u.description.properName from User u].
[7, 32] The state field path ‘u.description.properName’ cannot be resolved to a valid type.

Hi,
You cannot use metaproperties in JPQL queries.
They are not known to ORM data loading mechanism.

1 Like