Problem with Composition Relation Cannot be cast to class org.eclipse.persistence.descriptors.changetracking.ChangeTracker

Hi, i have a problem with an Entity. When I edit a Cliente and I create a new Attività all works fine, I can add many Attività. After that I tried to add other Entity like Appezzamenti, and when I try to save Cliente I get This Error:

ClassCastException: class com.company.innoagri.entity.Attivita cannot be cast to class org.eclipse.persistence.descriptors.changetracking.ChangeTracker

if I remove all Attività then I can save other entity related to Cliente like Appezzamento or ListinoCliente etc… What I’m doing wrong?

if I try to remove Attività from Cliente I get:

IllegalStateException: The entity 'com.company.innoagri.entity.Attivita-1816 [managed]' is is not a ChangeTracker

The problem seems to be only in the Composition Relationship

Thanks

@JmixEntity
@Table(name = "CLIENTE")
@Entity
public class Cliente {
    @JmixGeneratedValue
    @Column(name = "ID", nullable = false)
    @Id
    private Long id;

    @OnDelete(DeletePolicy.CASCADE)
    @Composition
    @OneToMany(mappedBy = "cliente")
    private List<Fattura> fatture;

    @Column(name = "SOCIETA")
    private Boolean societa;

    @Column(name = "DISATTIVATO")
    private Boolean disattivato;

    @OnDelete(DeletePolicy.CASCADE)
    @Composition
    @OneToMany(mappedBy = "cliente")
    private List<ListinoCliente> listini;

    @OnDelete(DeletePolicy.CASCADE)
    @Composition
    @OneToMany(mappedBy = "cliente")
    private List<Appezzamento> appezzamenti;

    @CaseConversion
    @Column(name = "RAGIONE_SOCIALE")
    private String ragioneSociale;

    @CaseConversion
    @Column(name = "NOME")
    private String nome;

    @CaseConversion
    @Column(name = "COGNOME")
    private String cognome;

    @CaseConversion
    @Column(name = "PIVA")
    private String piva;

    @CaseConversion
    @Column(name = "CODICE_FISCALE")
    private String codiceFiscale;

    @Column(name = "TELEFONO")
    private String telefono;

    @Column(name = "CELLULARE")
    private String cellulare;

    @Column(name = "LOCALITA")
    private String localita;

    @Column(name = "INDIRIZZO")
    private String indirizzo;

    @Column(name = "COMUNE")
    private String comune;

    @Column(name = "CAP", length = 5)
    private String cap;

    @CaseConversion
    @Column(name = "PROVINCIA", length = 2)
    private String provincia;

    @Column(name = "EMAIL")
    private String email;

    @Column(name = "PEC")
    private String pec;

    @Column(name = "VERSION", nullable = false)
    @Version
    private Integer version;

    @CreatedBy
    @Column(name = "CREATED_BY")
    private String createdBy;

    @CreatedDate
    @Column(name = "CREATED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdDate;

    @LastModifiedBy
    @Column(name = "LAST_MODIFIED_BY")
    private String lastModifiedBy;

    @LastModifiedDate
    @Column(name = "LAST_MODIFIED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastModifiedDate;

    @DeletedBy
    @Column(name = "DELETED_BY")
    private String deletedBy;

    @DeletedDate
    @Column(name = "DELETED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date deletedDate;

    @TenantId
    @Column(name = "TENANT")
    private String tenant;

    @OnDelete(DeletePolicy.CASCADE)
    @Composition
    @OneToMany(mappedBy = "cliente")
    private List<Attivita> attivita;

    public Boolean getDisattivato() {
        return disattivato;
    }

    public void setDisattivato(Boolean disattivato) {
        this.disattivato = disattivato;
    }

    public List<Attivita> getAttivita() {
        return attivita;
    }

    public void setAttivita(List<Attivita> attivita) {
        this.attivita = attivita;
    }

    public List<Fattura> getFatture() {
        return fatture;
    }

    public void setFatture(List<Fattura> fatture) {
        this.fatture = fatture;
    }

    public List<ListinoCliente> getListini() {
        return listini;
    }

    public void setListini(List<ListinoCliente> listini) {
        this.listini = listini;
    }

    public Boolean getSocieta() {
        return societa;
    }

    public void setSocieta(Boolean societa) {
        this.societa = societa;
    }

    public List<Appezzamento> getAppezzamenti() {
        return appezzamenti;
    }

    public void setAppezzamenti(List<Appezzamento> appezzamenti) {
        this.appezzamenti = appezzamenti;
    }

    public String getTenant() {
        return tenant;
    }

    public void setTenant(String tenant) {
        this.tenant = tenant;
    }

    public String getPec() {
        return pec;
    }

    public void setPec(String pec) {
        this.pec = pec;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getProvincia() {
        return provincia;
    }

    public void setProvincia(String provincia) {
        this.provincia = provincia;
    }

    public String getCap() {
        return cap;
    }

    public void setCap(String cap) {
        this.cap = cap;
    }

    public String getComune() {
        return comune;
    }

    public void setComune(String comune) {
        this.comune = comune;
    }

    public String getIndirizzo() {
        return indirizzo;
    }

    public void setIndirizzo(String indirizzo) {
        this.indirizzo = indirizzo;
    }

    public String getLocalita() {
        return localita;
    }

    public void setLocalita(String localita) {
        this.localita = localita;
    }

    public String getCellulare() {
        return cellulare;
    }

    public void setCellulare(String cellulare) {
        this.cellulare = cellulare;
    }

    public String getTelefono() {
        return telefono;
    }

    public void setTelefono(String telefono) {
        this.telefono = telefono;
    }

    public String getCodiceFiscale() {
        return codiceFiscale;
    }

    public void setCodiceFiscale(String codiceFiscale) {
        this.codiceFiscale = codiceFiscale;
    }

    public String getPiva() {
        return piva;
    }

    public void setPiva(String piva) {
        this.piva = piva;
    }

    public String getCognome() {
        return cognome;
    }

    public void setCognome(String cognome) {
        this.cognome = cognome;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getRagioneSociale() {
        return ragioneSociale;
    }

    public void setRagioneSociale(String ragioneSociale) {
        this.ragioneSociale = ragioneSociale;
    }

    public Date getDeletedDate() {
        return deletedDate;
    }

    public void setDeletedDate(Date deletedDate) {
        this.deletedDate = deletedDate;
    }

    public String getDeletedBy() {
        return deletedBy;
    }

    public void setDeletedBy(String deletedBy) {
        this.deletedBy = deletedBy;
    }

    public Date getLastModifiedDate() {
        return lastModifiedDate;
    }

    public void setLastModifiedDate(Date lastModifiedDate) {
        this.lastModifiedDate = lastModifiedDate;
    }

    public String getLastModifiedBy() {
        return lastModifiedBy;
    }

    public void setLastModifiedBy(String lastModifiedBy) {
        this.lastModifiedBy = lastModifiedBy;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }


    @DependsOnProperties({"nome", "cognome"})
    public String getDisplayName() {
        return String.format("%s %s ", (cognome != null ? cognome : ""),
                (nome != null ? nome : "")).trim();
    }

    @InstanceName
    @DependsOnProperties({"ragioneSociale", "nome", "cognome"})
    public String getCliente() {
        if(Objects.nonNull(this.ragioneSociale) && !this.ragioneSociale.isEmpty())
            return this.ragioneSociale;
        else
            return this.nome + " " + this.cognome;

    }

and the Entity Attività

@JmixEntity
@Table(name = "ATTIVITA", indexes = {
        @Index(name = "IDX_ATTIVITA_COLLABORATORE", columnList = "COLLABORATORE_ID"),
        @Index(name = "IDX_ATTIVITA_LAVORAZIONE", columnList = "LAVORAZIONE_ID"),
        @Index(name = "IDX_ATTIVITA_MEZZO", columnList = "MEZZO_ID"),
        @Index(name = "IDX_ATTIVITA_FATTURA", columnList = "FATTURA_ID"),
        @Index(name = "IDX_ATTIVITA_CLIENTE", columnList = "CLIENTE_ID")
})
@Entity
public class Attivita {
    @JmixGeneratedValue
    @Column(name = "ID", nullable = false)
    @Id
    private Long id;

    @JoinColumn(name = "CLIENTE_ID", nullable = false)
    @NotNull
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Cliente cliente;

    @TenantId
    @Column(name = "TENANT")
    private String tenant;

    @Column(name = "ORE_COLLABORATORE")
    private Double oreCollaboratore;

    @Column(name = "NOTE")
    @Lob
    private String note;

    @JoinColumn(name = "COLLABORATORE_ID", nullable = false)
    @NotNull
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private User collaboratore;

    @Column(name = "QTA")
    private Double qta;

    @Column(name = "ORA_INIZIO")
    @Temporal(TemporalType.TIME)
    private Date oraInizio;

    @Column(name = "ORA_FINE")
    @Temporal(TemporalType.TIME)
    private Date oraFine;

    @Column(name = "DURATA")
    private Double durata;

    @Column(name = "VALORE")
    private Double valore;

    @Column(name = "UNITA_MISURA")
    private String unitaMisura;

    @JoinColumn(name = "LAVORAZIONE_ID", nullable = false)
    @NotNull
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Lavorazione lavorazione;

    @NotNull
    @Column(name = "DATA_", nullable = false)
    private LocalDate data;

    @OnDelete(DeletePolicy.UNLINK)
    @JoinTable(name = "ATTIVITA_APPEZZAMENTO_LINK",
            joinColumns = @JoinColumn(name = "ATTIVITA_ID", referencedColumnName = "ID"),
            inverseJoinColumns = @JoinColumn(name = "APPEZZAMENTO_ID", referencedColumnName = "ID"))
    @ManyToMany(fetch = FetchType.EAGER)
    private List<Appezzamento> appezzamenti;

    public String getTenant() {
        return tenant;
    }

    public void setTenant(String tenant) {
        this.tenant = tenant;
    }

    @Column(name = "PREZZO")
    private Double prezzo;

    @Column(name = "VERIFICATO")
    private Boolean verificato;

    @Column(name = "DA_FATTURARE")
    private Boolean daFatturare;

    @Column(name = "FATTURATO")
    private Boolean fatturato;

    @JoinColumn(name = "MEZZO_ID")
    @ManyToOne(fetch = FetchType.LAZY)
    private Mezzo mezzo;

    @JoinColumn(name = "FATTURA_ID")
    @ManyToOne(fetch = FetchType.LAZY)
    private Fattura fattura;

    @Column(name = "VERSION", nullable = false)
    @Version
    private Integer version;

    @CreatedBy
    @Column(name = "CREATED_BY")
    private String createdBy;

    @CreatedDate
    @Column(name = "CREATED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdDate;

    @LastModifiedBy
    @Column(name = "LAST_MODIFIED_BY")
    private String lastModifiedBy;

    @LastModifiedDate
    @Column(name = "LAST_MODIFIED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastModifiedDate;

    @DeletedBy
    @Column(name = "DELETED_BY")
    private String deletedBy;

    @DeletedDate
    @Column(name = "DELETED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date deletedDate;

    public void setAppezzamenti(List<Appezzamento> appezzamenti) {
        this.appezzamenti = appezzamenti;
    }

    public List<Appezzamento> getAppezzamenti() {
        return appezzamenti;
    }

    public Cliente getCliente() {
        return cliente;
    }

    public void setCliente(Cliente cliente) {
        this.cliente = cliente;
    }

    public Fattura getFattura() {
        return fattura;
    }

    public void setFattura(Fattura fattura) {
        this.fattura = fattura;
    }

    public Mezzo getMezzo() {
        return mezzo;
    }

    public void setMezzo(Mezzo mezzo) {
        this.mezzo = mezzo;
    }

    public Boolean getFatturato() {
        return fatturato;
    }

    public void setFatturato(Boolean fatturato) {
        this.fatturato = fatturato;
    }

    public Boolean getDaFatturare() {
        return daFatturare;
    }

    public void setDaFatturare(Boolean daFatturare) {
        this.daFatturare = daFatturare;
    }

    public Boolean getVerificato() {
        return verificato;
    }

    public void setVerificato(Boolean verificato) {
        this.verificato = verificato;
    }

    public Double getPrezzo() {
        return prezzo;
    }

    public void setPrezzo(Double prezzo) {
        this.prezzo = prezzo;
    }

    public LocalDate getData() {
        return data;
    }

    public void setData(LocalDate data) {
        this.data = data;
    }

    public Lavorazione getLavorazione() {
        return lavorazione;
    }

    public void setLavorazione(Lavorazione lavorazione) {
        this.lavorazione = lavorazione;
    }

    public UM getUnitaMisura() {
        return unitaMisura == null ? null : UM.fromId(unitaMisura);
    }

    public void setUnitaMisura(UM unitaMisura) {
        this.unitaMisura = unitaMisura == null ? null : unitaMisura.getId();
    }

    public Double getValore() {
        return valore;
    }

    public void setValore(Double valore) {
        this.valore = valore;
    }

    public Double getDurata() {
        return durata;
    }

    public void setDurata(Double durata) {
        this.durata = durata;
    }

    public Date getOraFine() {
        return oraFine;
    }

    public void setOraFine(Date oraFine) {
        this.oraFine = oraFine;
    }

    public Date getOraInizio() {
        return oraInizio;
    }

    public void setOraInizio(Date oraInizio) {
        this.oraInizio = oraInizio;
    }

    public Double getQta() {
        return qta;
    }

    public void setQta(Double qta) {
        this.qta = qta;
    }

    public User getCollaboratore() {
        return collaboratore;
    }

    public void setCollaboratore(User collaboratore) {
        this.collaboratore = collaboratore;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public Double getOreCollaboratore() {
        return oreCollaboratore;
    }

    public void setOreCollaboratore(Double oreCollaboratore) {
        this.oreCollaboratore = oreCollaboratore;
    }

    public Date getDeletedDate() {
        return deletedDate;
    }

    public void setDeletedDate(Date deletedDate) {
        this.deletedDate = deletedDate;
    }

    public String getDeletedBy() {
        return deletedBy;
    }

    public void setDeletedBy(String deletedBy) {
        this.deletedBy = deletedBy;
    }

    public Date getLastModifiedDate() {
        return lastModifiedDate;
    }

    public void setLastModifiedDate(Date lastModifiedDate) {
        this.lastModifiedDate = lastModifiedDate;
    }

    public String getLastModifiedBy() {
        return lastModifiedBy;
    }

    public void setLastModifiedBy(String lastModifiedBy) {
        this.lastModifiedBy = lastModifiedBy;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
}
java.lang.ClassCastException: class com.company.innoagri.entity.Attivita cannot be cast to class org.eclipse.persistence.descriptors.changetracking.ChangeTracker (com.company.innoagri.entity.Attivita and org.eclipse.persistence.descriptors.changetracking.ChangeTracker are in unnamed module of loader 'app')
	at io.jmix.eclipselink.impl.EntityChangedEventManager.internalCollect(EntityChangedEventManager.java:141)
	at io.jmix.eclipselink.impl.EntityChangedEventManager.collect(EntityChangedEventManager.java:121)
	at io.jmix.eclipselink.impl.JpaDataStore.beforeSaveTransactionCommit(JpaDataStore.java:427)
	at io.jmix.core.datastore.AbstractDataStore.save(AbstractDataStore.java:229)
	at io.jmix.eclipselink.impl.JpaDataStore.save(JpaDataStore.java:227)
	at io.jmix.core.impl.UnconstrainedDataManagerImpl.saveContextToStore(UnconstrainedDataManagerImpl.java:257)
	at io.jmix.core.impl.UnconstrainedDataManagerImpl.save(UnconstrainedDataManagerImpl.java:216)
	at io.jmix.ui.model.impl.DataContextImpl.commitToDataManager(DataContextImpl.java:712)
	at io.jmix.ui.model.impl.DataContextImpl.performCommit(DataContextImpl.java:697)
	at io.jmix.ui.model.impl.DataContextImpl.commit(DataContextImpl.java:658)
	at io.jmix.ui.screen.StandardEditor.lambda$commitChanges$9(StandardEditor.java:427)
	at io.jmix.ui.screen.StandardEditor.commitChanges(StandardEditor.java:456)
	at io.jmix.ui.screen.StandardEditor.closeWithCommit(StandardEditor.java:626)
	at io.jmix.ui.screen.StandardEditor.commitAndClose(StandardEditor.java:580)
	at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
	at io.jmix.ui.action.BaseAction.actionPerform(BaseAction.java:220)
	at io.jmix.ui.component.impl.ButtonImpl.buttonClicked(ButtonImpl.java:75)
	at io.jmix.ui.widget.JmixButton.fireClick(JmixButton.java:77)
	at com.vaadin.ui.Button$1.click(Button.java:57)
	at jdk.internal.reflect.GeneratedMethodAccessor132.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:153)
	at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:115)
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:442)
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:407)
	at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:275)
	at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:83)
	at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
	at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1636)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:465)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
	at io.jmix.core.impl.logging.LogMdcFilter.doFilterInternal(LogMdcFilter.java:28)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:337)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:122)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:116)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:126)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:81)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:109)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:106)
	at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:97)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:147)
	at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90)
	at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:112)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:82)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.session.DisableEncodeUrlFilter.doFilterInternal(DisableEncodeUrlFilter.java:42)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:221)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:186)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:389)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:926)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1791)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.base/java.lang.Thread.run(Thread.java:834)

Hello,

Could you provide an example project with the structure of your entities please? I can’t reproduce the problem with just these two entities. My guess is that entities like Appezzamento and ListinoCliente have composite keys and would like to see their structure.

I put here the Entities

package com.company.innoagri.entity;

import io.jmix.core.DeletePolicy;
import io.jmix.core.annotation.DeletedBy;
import io.jmix.core.annotation.DeletedDate;
import io.jmix.core.annotation.TenantId;
import io.jmix.core.entity.annotation.JmixGeneratedValue;
import io.jmix.core.entity.annotation.OnDeleteInverse;
import io.jmix.core.metamodel.annotation.DependsOnProperties;
import io.jmix.core.metamodel.annotation.InstanceName;
import io.jmix.core.metamodel.annotation.JmixEntity;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@JmixEntity
@Table(name = "APPEZZAMENTO", indexes = {
        @Index(name = "IDX_APPEZZAMENTO_VARIETA", columnList = "VARIETA_ID"),
        @Index(name = "IDX_APPEZZAMENTO_CLIENTE", columnList = "CLIENTE_ID")
})
@Entity
public class Appezzamento {
    @JmixGeneratedValue
    @Column(name = "ID", nullable = false)
    @Id
    private Long id;

    @Column(name = "DENOMINAZIONE")
    private String denominazione;

    @Column(name = "COMUNE")
    private String comune;

    @Column(name = "ANNO_IMPIANTO")
    private Integer annoImpianto;

    @Column(name = "ANNO_SOVRAINNESTO")
    private Integer annoSovrainnesto;

    @Column(name = "SUPERFICIE")
    private Integer superficie;

    @Column(name = "DISTANZA_ACQUA")
    private Double distanzaAcqua;

    @Column(name = "DISTANZA_TRA_PIANTE")
    private Double distanzaTraPiante;

    @Column(name = "DISTANZA_TRA_FILARI")
    private Double distanzaTraFilari;

    @Column(name = "IRRIGATO")
    private Boolean irrigato;

    @Column(name = "TIPO_IRRIGAZIONE")
    private String tipoIrrigazione;

    @Column(name = "NOTE")
    @Lob
    private String note;

    @JoinColumn(name = "VARIETA_ID")
    @ManyToOne(fetch = FetchType.LAZY)
    private Varieta varieta;

    @Column(name = "VERSION", nullable = false)
    @Version
    private Integer version;

    @CreatedBy
    @Column(name = "CREATED_BY")
    private String createdBy;

    @CreatedDate
    @Column(name = "CREATED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdDate;

    @LastModifiedBy
    @Column(name = "LAST_MODIFIED_BY")
    private String lastModifiedBy;

    @LastModifiedDate
    @Column(name = "LAST_MODIFIED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastModifiedDate;

    @DeletedBy
    @Column(name = "DELETED_BY")
    private String deletedBy;

    @DeletedDate
    @Column(name = "DELETED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date deletedDate;

    @TenantId
    @Column(name = "TENANT")
    private String tenant;

    @OnDeleteInverse(DeletePolicy.CASCADE)
    @JoinColumn(name = "CLIENTE_ID", nullable = false)
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Cliente cliente;

    @JoinTable(name = "ATTIVITA_APPEZZAMENTO_LINK",
            joinColumns = @JoinColumn(name = "APPEZZAMENTO_ID", referencedColumnName = "ID"),
            inverseJoinColumns = @JoinColumn(name = "ATTIVITA_ID", referencedColumnName = "ID"))
    @ManyToMany
    private List<Attivita> attivita;

    public List<Attivita> getAttivita() {
        return attivita;
    }

    public void setAttivita(List<Attivita> attivita) {
        this.attivita = attivita;
    }

    public Cliente getCliente() {
        return cliente;
    }

    public void setCliente(Cliente cliente) {
        this.cliente = cliente;
    }

    public String getTenant() {
        return tenant;
    }

    public void setTenant(String tenant) {
        this.tenant = tenant;
    }

    public Varieta getVarieta() {
        return varieta;
    }

    public void setVarieta(Varieta varieta) {
        this.varieta = varieta;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public String getTipoIrrigazione() {
        return tipoIrrigazione;
    }

    public void setTipoIrrigazione(String tipoIrrigazione) {
        this.tipoIrrigazione = tipoIrrigazione;
    }

    public Boolean getIrrigato() {
        return irrigato;
    }

    public void setIrrigato(Boolean irrigato) {
        this.irrigato = irrigato;
    }

    public Double getDistanzaTraFilari() {
        return distanzaTraFilari;
    }

    public void setDistanzaTraFilari(Double distanzaTraFilari) {
        this.distanzaTraFilari = distanzaTraFilari;
    }

    public Double getDistanzaTraPiante() {
        return distanzaTraPiante;
    }

    public void setDistanzaTraPiante(Double distanzaTraPiante) {
        this.distanzaTraPiante = distanzaTraPiante;
    }

    public Double getDistanzaAcqua() {
        return distanzaAcqua;
    }

    public void setDistanzaAcqua(Double distanzaAcqua) {
        this.distanzaAcqua = distanzaAcqua;
    }

    public Integer getSuperficie() {
        return superficie;
    }

    public void setSuperficie(Integer superficie) {
        this.superficie = superficie;
    }

    public Integer getAnnoSovrainnesto() {
        return annoSovrainnesto;
    }

    public void setAnnoSovrainnesto(Integer annoSovrainnesto) {
        this.annoSovrainnesto = annoSovrainnesto;
    }

    public Integer getAnnoImpianto() {
        return annoImpianto;
    }

    public void setAnnoImpianto(Integer annoImpianto) {
        this.annoImpianto = annoImpianto;
    }

    public String getComune() {
        return comune;
    }

    public void setComune(String comune) {
        this.comune = comune;
    }

    public String getDenominazione() {
        return denominazione;
    }

    public void setDenominazione(String denominazione) {
        this.denominazione = denominazione;
    }

    public Date getDeletedDate() {
        return deletedDate;
    }

    public void setDeletedDate(Date deletedDate) {
        this.deletedDate = deletedDate;
    }

    public String getDeletedBy() {
        return deletedBy;
    }

    public void setDeletedBy(String deletedBy) {
        this.deletedBy = deletedBy;
    }

    public Date getLastModifiedDate() {
        return lastModifiedDate;
    }

    public void setLastModifiedDate(Date lastModifiedDate) {
        this.lastModifiedDate = lastModifiedDate;
    }

    public String getLastModifiedBy() {
        return lastModifiedBy;
    }

    public void setLastModifiedBy(String lastModifiedBy) {
        this.lastModifiedBy = lastModifiedBy;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @InstanceName
    @DependsOnProperties({"varieta", "denominazione"})
    public String getInstanceName() {
        return String.format("%s - %s (%s MQ)", varieta.getVarieta(), denominazione, superficie.toString());
    }
}
package com.company.innoagri.entity;

import io.jmix.core.DeletePolicy;
import io.jmix.core.annotation.DeletedBy;
import io.jmix.core.annotation.DeletedDate;
import io.jmix.core.annotation.TenantId;
import io.jmix.core.entity.annotation.JmixGeneratedValue;
import io.jmix.core.entity.annotation.OnDeleteInverse;
import io.jmix.core.metamodel.annotation.JmixEntity;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

@JmixEntity
@Table(name = "LISTINO_CLIENTE", indexes = {
        @Index(name = "IDX_LISTINO_CLIENTE_LAVORAZIONE", columnList = "LAVORAZIONE_ID"),
        @Index(name = "IDX_LISTINO_CLIENTE_CLIENTE", columnList = "CLIENTE_ID")
})
@Entity
public class ListinoCliente {
    @JmixGeneratedValue
    @Column(name = "ID", nullable = false)
    @Id
    private Long id;

    @NotNull
    @JoinColumn(name = "LAVORAZIONE_ID", nullable = false)
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Lavorazione lavorazione;

    @Column(name = "SCONTO")
    private Double sconto = 0.0;

    @Column(name = "PREZZO_CLIENTE")
    private Double prezzoCliente;

    @Column(name = "PREZZO_UM")
    private Double prezzoUm;

    @Column(name = "VERSION", nullable = false)
    @Version
    private Integer version;

    @CreatedBy
    @Column(name = "CREATED_BY")
    private String createdBy;

    @CreatedDate
    @Column(name = "CREATED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdDate;

    @LastModifiedBy
    @Column(name = "LAST_MODIFIED_BY")
    private String lastModifiedBy;

    @LastModifiedDate
    @Column(name = "LAST_MODIFIED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastModifiedDate;

    @DeletedBy
    @Column(name = "DELETED_BY")
    private String deletedBy;

    @DeletedDate
    @Column(name = "DELETED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date deletedDate;

    @TenantId
    @Column(name = "TENANT")
    private String tenant;

    @OnDeleteInverse(DeletePolicy.CASCADE)
    @JoinColumn(name = "CLIENTE_ID")
    @ManyToOne(fetch = FetchType.LAZY)
    private Cliente cliente;

    public Double getPrezzoUm() {
        return prezzoUm;
    }

    public void setPrezzoUm(Double prezzoUm) {
        this.prezzoUm = prezzoUm;
    }

    public Double getPrezzoCliente() {
        return prezzoCliente;
    }

    public void setPrezzoCliente(Double prezzoCliente) {
        this.prezzoCliente = prezzoCliente;
    }

    public Cliente getCliente() {
        return cliente;
    }

    public void setCliente(Cliente cliente) {
        this.cliente = cliente;
    }

    public Double getSconto() {
        return sconto;
    }

    public void setSconto(Double sconto) {
        this.sconto = sconto;
    }

    public Lavorazione getLavorazione() {
        return lavorazione;
    }

    public void setLavorazione(Lavorazione lavorazione) {
        this.lavorazione = lavorazione;
    }

    public String getTenant() { return tenant; }

    public void setTenant(String value) {
        this.tenant = value;
    }

    public Date getDeletedDate() {
        return deletedDate;
    }

    public void setDeletedDate(Date deletedDate) {
        this.deletedDate = deletedDate;
    }

    public String getDeletedBy() {
        return deletedBy;
    }

    public void setDeletedBy(String deletedBy) {
        this.deletedBy = deletedBy;
    }

    public Date getLastModifiedDate() {
        return lastModifiedDate;
    }

    public void setLastModifiedDate(Date lastModifiedDate) {
        this.lastModifiedDate = lastModifiedDate;
    }

    public String getLastModifiedBy() {
        return lastModifiedBy;
    }

    public void setLastModifiedBy(String lastModifiedBy) {
        this.lastModifiedBy = lastModifiedBy;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

}



package com.company.innoagri.entity;

import io.jmix.core.DeletePolicy;
import io.jmix.core.annotation.TenantId;
import io.jmix.core.entity.annotation.JmixGeneratedValue;
import io.jmix.core.entity.annotation.OnDeleteInverse;
import io.jmix.core.metamodel.annotation.InstanceName;
import io.jmix.core.metamodel.annotation.JmixEntity;

import javax.persistence.*;
import java.time.LocalDate;

@JmixEntity
@Table(name = "PREZZO_LAVORAZIONE", indexes = {
        @Index(name = "IDX_PREZZO_LAVORAZIONE_LAVORAZIONE", columnList = "LAVORAZIONE_ID")
})
@Entity
public class PrezzoLavorazione {
    @JmixGeneratedValue
    @Column(name = "ID", nullable = false)
    @Id
    private Long id;

    @InstanceName
    @Column(name = "DATA_INIZIO")
    private LocalDate dataInizio;

    @Column(name = "IN_VIGORE")
    private Boolean inVigore;

    @Column(name = "DATA_FINE")
    private LocalDate dataFine;

    @Column(name = "UNITA_DI_MISURA")
    private String unitaDiMisura;

    @Column(name = "PREZZO")
    private Double prezzo;

    @Column(name = "PREZZO_ORA")
    private Double prezzoOra;

    @TenantId
    @Column(name = "TENANT")
    private String tenant;

    @OnDeleteInverse(DeletePolicy.CASCADE)
    @JoinColumn(name = "LAVORAZIONE_ID", nullable = false)
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Lavorazione lavorazione;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Lavorazione getLavorazione() {
        return lavorazione;
    }

    public void setLavorazione(Lavorazione lavorazione) {
        this.lavorazione = lavorazione;
    }

    public String getTenant() {
        return tenant;
    }

    public void setTenant(String tenant) {
        this.tenant = tenant;
    }

    public Boolean getInVigore() {
        return inVigore;
    }

    public void setInVigore(Boolean inVigore) {
        this.inVigore = inVigore;
    }

    public Double getPrezzoOra() {
        return prezzoOra;
    }

    public void setPrezzoOra(Double prezzoOra) {
        this.prezzoOra = prezzoOra;
    }

    public Double getPrezzo() {
        return prezzo;
    }

    public void setPrezzo(Double prezzo) {
        this.prezzo = prezzo;
    }

    public UM getUnitaDiMisura() {
        return unitaDiMisura == null ? null : UM.fromId(unitaDiMisura);
    }

    public void setUnitaDiMisura(UM unitaDiMisura) {
        this.unitaDiMisura = unitaDiMisura == null ? null : unitaDiMisura.getId();
    }

    public LocalDate getDataFine() {
        return dataFine;
    }

    public void setDataFine(LocalDate dataFine) {
        this.dataFine = dataFine;
    }

    public LocalDate getDataInizio() {
        return dataInizio;
    }

    public void setDataInizio(LocalDate dataInizio) {
        this.dataInizio = dataInizio;
    }

}


This is the project

Hello, @roveda.marco !

The problem is caused by FetchType.EAGER of field Attivita.appezzamenti:
Снимок экрана 2023-05-25 в 00.04.15

Please, use FetchType.LAZY instead.
The EAGER fetch type is not supported by Jmix Framework as it contradicts the concept of fetch plans and leads to various problems, including but not limited to the one you described.

If any issues arise that led to the use of FetchType.EAGER, please let me know. I’ll be glad to help!

Regards,
Dmitry

Hi, thanks, it’s works but now I have a strange behavior: the method getAppezzamenti() gives me entity 2 times.

When I invoke

getEditedEntity().getCliente().getAppezzamenti()

the output is

{[com.company.innoagri.entity.Appezzamento-1101 [detached], com.company.innoagri.entity.Appezzamento-1101 [detached]]}

a list with 2 time the same entity

This is Cliente Entity detail

 public List<Appezzamento> getAppezzamenti() {
        return appezzamenti;
    }

  public void setAppezzamenti(List<Appezzamento> appezzamenti) {
        this.appezzamenti = appezzamenti;
    }

and this Appezzamenti detail


    @JoinTable(name = "ATTIVITA_APPEZZAMENTO_LINK",
            joinColumns = @JoinColumn(name = "APPEZZAMENTO_ID", referencedColumnName = "ID"),
            inverseJoinColumns = @JoinColumn(name = "ATTIVITA_ID", referencedColumnName = "ID"))
    @ManyToMany
    private List<Attivita> attivita;
    @OnDeleteInverse(DeletePolicy.CASCADE)
    @JoinColumn(name = "CLIENTE_ID", nullable = false)
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Cliente cliente;

Hello, Marco!

Indeed, it looks strange.
Can this problem be reproduced on the project, provided above?
If so, could you, please, add a test to the project to demonstrate the issue?

(As I remember, Attivita contains many other required entity relations which should be set up and may potentially influence the reproducibility of the issue. The project and its settings could also take effect. It would be better to have concrete steps to reproduce the problem)

Regards,
Dmitry

Hi Dmitry, thanks for your answer

the problem is still reproducible in the project. The steps are:

  • create a Cliente
  • add some Appezzamenti (also 1)
  • create an Attività.

I also try to delete composition and make new composition of appezzamenti in Cliente but the behavior is the same

in AttivitaEdit.java the - log.info - shows the problem, I solved it by dataManager query, but log.info show the array from get method.

@Subscribe
    public void onAfterShow(AfterShowEvent event) {
        if(Objects.isNull(getEditedEntity().getCliente())){
            clienteField.setVisible(true);
        }else {
            if(Objects.nonNull(getEditedEntity().getCliente().getAppezzamenti())){
                log.info("Appezzamenti " + getEditedEntity().getCliente().getAppezzamenti().toString());
                List<Appezzamento> aps = dataManager.load(Appezzamento.class)
                                .query("select e from Appezzamento e where e.cliente = :cliente")
                                        .parameter("cliente",getEditedEntity().getCliente() )
                                                .list();
                appezzamentoesDc.setItems(aps);
                appezzamentiField.setValue(getEditedEntity().getAppezzamenti());
            }
        }
    }

Hi, Marco
I’ve tried this steps:

  1. Download current version of your project (03 Jun 2023), create empty postgres db.
  2. create a Cliente
  3. add some Appezzamenti (also 1)
  4. create an Attività, save, reopen
    AR: no duplication on line you mentioned before
    изображение

Could you please consider providing a simple reproducible example project with the test already included, eliminating the need for manual creation of data? This would be greatly appreciated as it would allow me to accurately reproduce the issue, which I am currently unsure of the specific data required to trigger.
By providing such a project, I would be able to investigate the issue.

Regards,
Dmitry