API Update Entity with Composition Entities

This used to work, I don’t know if it’s an issue from a previous update. I have a Ticket with a composition child collection of Steps.

API Process:

  1. Create new TIcket + Steps with single message to API
  2. Select Ticket (with Steps) from API
  3. Update a field on a Step Message and Send Ticket + Steps to API to update step.
  4. Error, Step doesn’t have a reference back to ticket in the API, but I’m getting “Cannot get unfetched attribute [ticket] from detached object com.company.njuns.entity.Step-d0f7c0e2-e62d-1953-4674-94f9cf165071 [detached].”

I have no way of specifying the view, and this error I found EntityImportExport: 409. This service is trying to add the reference of Step back to Ticket but it can’t do this.

Hi,

What is the platform version do you use? Could you provide sample project?

I couldn’t reproduce the problem. I have tested on the 6.9.5 version.

Data model:

@NamePattern("%s|number")
@Table(name = "UBERJAR_TICKET")
@Entity(name = "uberjar$Ticket")
public class Ticket extends StandardEntity {
    private static final long serialVersionUID = -5708688890287368172L;

    @Column(name = "NUMBER_")
    protected String number;


    @Composition
    @OnDelete(DeletePolicy.CASCADE)
    @OneToMany(mappedBy = "ticket")
    protected List<Step> steps;

    //getters and setters
}

@NamePattern("%s|name")
@Table(name = "UBERJAR_STEP")
@Entity(name = "uberjar$Step")
public class Step extends StandardEntity {
    private static final long serialVersionUID = -647301058479062547L;

    @Column(name = "NAME")
    protected String name;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "TICKET_ID")
    protected Ticket ticket;

    //getters and setters
}

JSON request body:

{
    "_entityName": "uberjar$Ticket",
    "_instanceName": "ticket",
    "id": "c88791f7-bd14-faba-854a-2de06d27cec1",
    "number": "ticket",
    "version": 1,
    "steps": [
        {
            "_entityName": "uberjar$Step",
            "_instanceName": "Step",
            "id": "c7cd0f89-cf39-cc46-1d8d-4345f2fb1006",
            "name": "Step111",
            "version": 1
        }
    ]
}