Problem with NamePattern using multiple associations.

Hello,

I have an entity called Kontrolle (see code at the bottom) that uses a NamePattern that requires data from multiple object. In order to make this work, I have to create view that contains all required attributes. The minimal view does not work contain all required values.
But when I try to use the “Entity Inspector” or the “Global fts search”, this does not work since it uses a default view (_minimal or _local?).

In this case I get this error message:

QueryException:
Exception Description: The value e.ueberwachungssichtBetriebsstaette.betriebsstaette.betriebsstaette supplied to the query hint eclipselink.left-join-fetch navigated a non-existent relationship. The relationship betriebsstaette.betriebsstaette does not exist.
Query: ReadObjectQuery(referenceClass=Kontrolle sql=“SELECT ID, … FROM BALVILM_KONTROLLE WHERE ((ID = ?) AND (DELETE_TS IS NULL))”)

Do you see a solution for this issue? I have these ideas:

  1. Add a String property ‘caption’ to Kontrolle and save the caption then the entity is updated. But this creates redundancy and the property has to be updated when Kontrolle or Betriebsstaette changes which is quite cumbersome.
  2. Override the view that is used in “Entity Inspector” and the “Global fts search”. But I am not sure if this is possible.
  3. Extend @NamePattern/ minimal view so that it can deal with this situation.

What do you thing?

Thanks in advance.

Yours,
Joerg

Here are the entities


@Table(name = "BALVILM_KONTROLLE")
@Entity(name = "balvilm$Kontrolle")
@NamePattern("#getCaption|ueberwachungssichtBetriebsstaette,kontrolldatum")
public class Kontrolle extends BearbeitungsstandEntity {


    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "UEBERWACHUNGSSICHT_BTS_ID")
    protected UeberwachungssichtBetriebsstaette ueberwachungssichtBetriebsstaette;

...

    public String getCaption() {
        String formatiertesKontrolldatum = AppBeans.get(DatatypeFormatter.class).formatDate(kontrolldatum);
        return ueberwachungssichtBetriebsstaette.getBetriebsstaette().getBezeichnung() + " (" + formatiertesKontrolldatum + ")" + " (" + this.getClass().getSimpleName() + ")";

    }
}

--------

@NamePattern("#getCaption|betriebsstaette,ueberwachungssicht")
@Table(name = "BALVILM_UEBERWACHUNGSSICHT_BTS")
@Entity(name = "balvilm$UeberwachungssichtBetriebsstaette")
public class UeberwachungssichtBetriebsstaette extends StandardEntity {


    @OnDelete(DeletePolicy.UNLINK)
    @OneToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "BETRIEBSSTAETTE_ID")
    protected Betriebsstaette betriebsstaette;

	
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "UEBERWACHUNGSSICHT_ID")
    protected Ueberwachungssicht ueberwachungssicht;

...	
	
	public String getCaption() {
        return betriebsstaette.getBezeichnung() + " (" + ueberwachungssicht.getBezeichnung() + ")";
    }

}

--------

@NamePattern("%s|bezeichnung")
@Table(name = "BALVILM_UEBERWACHUNGSSICHT")
@Entity(name = "balvilm$Ueberwachungssicht")
public class Ueberwachungssicht extends StandardEntity {
    private static final long serialVersionUID = -39963171871445890L;

    @Column(name = "BEZEICHNUNG", nullable = false)
    protected String bezeichnung;
}

----

@Table(name = "BALVILM_BETRIEBSSTAETTE")
@Entity(name = "balvilm$Betriebsstaette")
@NamePattern("%s|bezeichnung")
public class Betriebsstaette extends MandantEntity {
    private static final long serialVersionUID = 4839563979247487690L;

    @Column(name = "BEZEICHNUNG")
    protected String bezeichnung;

	...
}

Hi Joerg,

Could you please reproduce the issue on a small test project?
I’m a bit lost in the object relations and names in German, sorry.

Hi Konstantin,

thanks for your quick answer. Sorry to confuse you with my complex german domain model. I created a demo project that is hopefully easier to understand.

After starting the app, please add a new Review instance, set the rating to any e.g. 5 and select an employee. Then open the “Entity Inspector” for Review. Now you should get the error.

Yours,
Joerg

name-pattern-demo.zip (422.9K)

Joerg,

It turned out to be a bug in the mechanism of creating a _minimal view. We’ve just fixed it for release 6.2.8+, the release will be available on October 12.

Thank you for the report and test project!

Fixed in 6.2.8.