Unfetched Attribute Access Error

Hi There!

I added the annotation


to the top of an Entity class (SystemCodeDetail) in order to get the instance name for the entity from another table (SystemCodeDetaiulText).

the getCaption() method is as follows:

@OneToMany(mappedBy = "code", fetch=FetchType.EAGER)
    protected Set<SystemCodeDetailText> texts;

public String getCaption()
    for(SystemCodeDetailText text : texts)
            return text.shortName;
    return "";

This all works as intended but now when accessing the screen of “SystemCodeDetail” I receive the error 2017-11-13_12h14_07

I am unable to figure out how the method above affects my entity in such a way… I have changed nothing else except adding the above annotation and method.

Hi Christian,

The @NamePattern annotation should define a list of attributes that should be loaded for the method to work. If you specify @NamePattern("#getCaption|texts"), the collection will be loaded (which is bad for performance BTW), but SystemCodeDetailText attributes languageCode.codeKey will not. So it won’t work anyway.

I would suggest denormalization, i.e. storing text.languageCode.codeKey value in the SystemCodeDetail entity. It can be done using entity listeners.

Hi Konstantin

Thank you for your reply.

The code as I’ve showed you above works for its intended purposes. We wanted to display text.shortName (stored in SystemCodeDetailText) as the instance name (of SystemCodeDetail) in other tables and that is what it does.

The problem was when we tried to access the SystemCodeDetail entity itself.

What we did was add texts to the SystemCodeDetail view:


This seemed to work initially. What we discovered was that when the screen was loaded initially (ie. the first 50 rows) it works. However, when we want to display the next 50 rows the same error appears:


BUT it seems to only be referencing the the first row since the rest of the rows do get loaded:


We don’t understand why its having trouble loading only the first entry…?

It can be a bug in ORM that we have recently fixed. What platform version do you use?
Also, setting Fetch Mode to BATCH explicitly for both texts and index attributes may help.

We are using Platform version 6.7.2.

Setting the Fetch Mode to BATCH for texts and index did, unfortunately, not resolve our problem.
This is a real head scratcher. It almost feels like it wants to display the first row before the data has arrived and by the time it wants to start filling rows 2 onwards the data has arrived.

Thank you for your help so far, Konstantin.


The bugs I was talking about were fixed by 6.7.2. Perhaps your case is something new.
We would be happy to find out the reason and fix a bug if it is a bug. Could you make a test project where the problem is reproduced?