Strange Reporting

I have an Entity TObject with an association to an Entity TContact (objEventIdContact) and to an Entity TSite(objSiteIdSite).

From the descriptor

  <data>
      <collection id="tObjectsDc" class="org.biooffice.bio4.entity.TObject">
         <fetchPlan extends="_base">
            <property name="objDetIdContact" fetchPlan="_instance_name"/>
            <property name="objEventIdContact" fetchPlan="_local"/>
            <property name="objSiteIdSite" fetchPlan="_local"/>
         </fetchPlan>
         <loader id="tObjectsDl" readOnly="false">
            <query>
               <![CDATA[select e from TObject e order by e.objCommonDescription]]>
            </query>
         </loader>
      </collection>

      <dataGrid id="tObjectsDataGrid" dataContainer="tObjectsDc" columnReorderingAllowed="true"
                multiSort="true" multiSortPriority="APPEND" selectionMode="MULTI"
                themeNames="row-stripes, compact, no-border, no-row-borders">

In the controller I use uiReportRunner

	Set<TObject> tObjects = tObjectsDataGrid.getSelectedItems();

	uiReportRunner.byReportEntity(report)
			.withOutputType(ReportOutputType.PDF)
			.withParametersDialogShowMode(ParametersDialogShowMode.NO)
			.addParam("Obj", tObjects)
			.addParam(JRParameter.REPORT_LOCALE, getLocale())
			.runAndShow();

In the band of the report I have

def result = []

def tObjects = params['Obj'];

tObjects.each(
    tObject-> {
        
        def sitCountry = "";
        if ( tObject.objSiteIdSite != null ) {
            sitCountry  = tObject.objSiteIdSite.sitCountry;
        }

        def SammlerName = "";
        if ( tObject.objEventIdContact != null ) {
            SammlerName = tObject.objEventIdContact.conLastName;
        }

        result.add([
            'sitCountry'       : sitCountry,
            'SammlerName'      : SammlerName
            ]
        );
    }
);

return result;

If I execute this report, the sitCountry from TSite (objSiteIdSite) is found and printed, but if I want to assign the conLastName from TContact (objEventIdContact), I get the following error

> io.jmix.reports.exception.ReportingException: An error occurred while loading data for band [Detail] and query [dataSet1]. Report name [Objekte 40x13 mm Etiketten]
> An error occurred while loading data for data set [dataSet1]
> Cannot get unfetched attribute [conLastName] from detached object org.biooffice.bio4.entity.TContact-1891 [detached].

What can I do ?

The association to objSiteIdSite is fetched, but the association to objEventIdContact not ?

How to force the fetching of the TContact Entity ?

Best regards

Felix

Hello,
> Cannot get unfetched attribute [conLastName] from detached object org.biooffice.bio4.entity.TContact-1891 [detached].
I would focus on this → this looks like you need to check the collection XML a bit. Can you see if that attribute is fetched for your list view datagrid or detail view?

What about this one
property name="objDetIdContact" fetchPlan="_instance_name"
what happens if you change the fetch plan to _base or _local.

Check the entity definitions too, under Data Model, do you have correct associations?
If it’s still not working, make an example application and share it on Github so we can look :slight_smile:
Kind regards,
Mladen

Hi Mladen

Before I did report this, I followed exactly the steps you propose

  • the view shows the related entity
  • the associations are corrected

And I did suspect this second relation to the same entity too, but not follow that path. ( In the real world application there are a lot more associations

            <property name="objAtlCommonIdReference" fetchPlan="_local"/>
            <property name="objAtlDetIdReference" fetchPlan="_local"/>
            <property name="objCommonIdReference" fetchPlan="_local"/>
            <property name="objDetIdReference" fetchPlan="_local"/>
            <property name="objDetIdTaxon" fetchPlan="_local"/>
            <property name="objDetIdContact" fetchPlan="_instance_name"/>
            <property name="objEventIdContact" fetchPlan="_local"/>
            <property name="objIdCollection" fetchPlan="_instance_name"/>
            <property name="objIdExcursion" fetchPlan="_local"/>
            <property name="objOriginIdContact" fetchPlan="_instance_name"/>
            <property name="objPreparationIdContact" fetchPlan="_instance_name"/>
            <property name="objSiteIdSite" fetchPlan="_local"/>
            <property name="objStorageLevel2" fetchPlan="_base"/>
            <property name="objStorageLevel1" fetchPlan="_base"/>
            <property name="objDetCf" fetchPlan="_base"/>
            <property name="objPropSex" fetchPlan="_base"/>
            <property name="objStorageNumberPrefix" fetchPlan="_base"/>
            <property name="objAddLkp1" fetchPlan="_base"/>

Today I did change the mentioned fetchplan from “_instance_name” to “_local”; and it is working !

To understand this behaviour, I will make a small testproject and keep you updated, what the reason for this strange reporting (strange for me) is ;/

Meanwhile, thank you for your support !

It’s good that it works!
Another hunch, please check if the entity has set its instance name in its definition?