NamePattern using a method on the parent not working in Jmix?

Our patient entity extends a person entity. In CUBA, the name pattern was declared like this: @NamePattern("#getName|firstName,lastName") - and it worked fine. getName() is a method of the parent entity (Person) - as are first and last name as well.

Upon migration, I get a an exception saying:

Caused by: org.springframework.security.authentication.InternalAuthenticationServiceException: java.lang.RuntimeException: Instance name method getName not found in meta class medflexj_Patient

… any ideas?

In my migrated project, NamePattern was converted into getInstanceName() like this:

@DependsOnProperties({"title", "startDate", "endDate"})
@InstanceName
public String getInstanceName() {
    return String.format("%s [%s - %s]", title, startDate, endDate);
}

Do you have getName method in your class annotated with InstanceName?

The migration didn’t touch mine; it left it as is. The @NamePattern annotation has a Deprecated mark on it, but that’s fine.

Just like this:

@JmixEntity
@NamePattern("#getName|firstName,lastName")
@Table(name = "MEDFLEXJ_PATIENT", indexes = {
        @Index(name = "IDX_MEDFLEXJ_PATIENT_ON_LEGACY_CODE", columnList = "LEGACY_CODE"),
        @Index(name = "IDX_MEDFLEXJ_PATIENT_ON_FIRST_LAST", columnList = "FIRST_NAME, LAST_NAME"),
        @Index(name = "IDX_MEDFLEXJ_PATIENT_ON_LAST_FIRST", columnList = "LAST_NAME, FIRST_NAME"),
        @Index(name = "IDX_MEDFLEXJ_PATIENT_ON_SSN", columnList = "SOCIAL_SECURITY_NUMBER"),
        @Index(name = "IDX_MEDFLEXJ_PATIENT_ON_RECTYTPE", columnList = "RECORD_TYPE")
})
@Entity(name = "medflexj_Patient")
public class Patient extends Person {

The getName method is a method of the Person class which Patient extends. The name attributes are also on the Person class. This is a very normal inheritance structure for Java.

The exception being thrown isn’t even correct - there is indeed a getName method - it’s on the parent class…which is completely valid.