I have a localizedStringEntity for storing user translated values, I use this in other entities
eg.
@JmixEntity
@Table(name = "OCTO_COUNTRY", uniqueConstraints = {
@UniqueConstraint(name = "IDX_OCTO_COUNTRY_UNQ", columnNames = {"TENANT_ID", "ISO_CODE", "DELETE_TS"})
})
@Entity(name = "octo_Country")
public class Country extends StandardTenantEntity {
private static final long serialVersionUID = 548912591307638405L;
@InstanceName
@NotNull
@Composition
@OnDelete(DeletePolicy.CASCADE)
@OneToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "NAME_ID", nullable = false)
protected LocalizedString name;
and
@JmixEntity
@Table(name = "OCTO_DOSSIER_TYPE")
@Entity(name = "octo_DossierType")
public class DossierType extends StandardTenantEntity {
private static final long serialVersionUID = 8465221778783351503L;
@InstanceName
@NotNull
@Composition
@OnDelete(DeletePolicy.CASCADE)
@OneToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "NAME_ID")
protected LocalizedString name;
The entities are identical, I have a browsescreen for each with a datacollection and using autoload.
<data readOnly="true">
<collection id="countriesDc" class="eu.octorilla.contact.model.Country" fetchPlan="_base">
<loader id="countriesDl">
<query>
<![CDATA[select e from octo_Country e]]>
</query>
</loader>
</collection>
</data>
<collection id="dossierTypesDc" class="eu.octorilla.dossier.domain.DossierType" fetchPlan="_local">
<loader id="dossierTypesDl">
<query>
<![CDATA[select e from octo_DossierType e]]>
</query>
</loader>
</collection>
</data>
I have an entity listener to get the user’s language so I know what string to display
@Component
@AllArgsConstructor
public class LocalizedStringEntityListener {
public static final String NAME = "localizedStringEntityListener";
private final CurrentUserRetriever currentUserRetriever;
@EventListener
void onLoad(EntityLoadingEvent<LocalizedString> event) {
event.getEntity().setCurrentLanguage(currentUserRetriever.getCurrentSessionLanguage());
}
}
When the fetchplan is _base the entityListener is not invoked, when it is _local it does work
EDIT: it looks like not specifying a fetchplan also gives the same issue