#Entity save incorrect values

1 messages · Page 1 of 1 (latest)

desert sigil
#

Hello! My entity doesn't save the values I need. Any idea what is causing this or how to fix this?

CREATE TABLE repair_contract_user (
    contract_id BIGSERIAL REFERENCES repair_contract (id) NOT NULL,
    repair_id BIGSERIAL REFERENCES repair_contract (id) NOT NULL
);
public class RepairContractUser {
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "contract_id", insertable = false, updatable = false)
    @JoinColumn(name = "repair_id", insertable = false, updatable = false)
    @ToString.Exclude
    private RepairContract repairContract;
}

public class RepairContract {
    @EmbeddedId
    private RepairContractKey id = new RepairContractKey();

    @ManyToOne(fetch = FetchType.LAZY)
    @MapsId("repairId")
    @ToString.Exclude
    private Repair repair;

    @ManyToOne(fetch = FetchType.LAZY)
    @MapsId("contractId")
    @ToString.Exclude
    private RentalContract contract;

    public static class RepairContractKey implements Serializable {
        private Long repairId;
        private Long contractId;
    }
}
                        // here RepairContract(id=RepairContract.RepairContractKey(repairId=69, contractId=8652))
                        final var repairContractUser = new RepairContractUser();
                        repairContractUser.setRepairContract(repairContract);
                        repairContractUser.setEmail(val.getEmail());
                        repairContractUser.setUser(user);

                        repairContractUserRepository.save(repairContractUser);
                        But in DB it saves 41 and 36
rose needleBOT
#

<@&987246399047479336> please have a look, thanks.

rose needleBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

desert sigil
#

@JoinColumn(name = "contract_id", insertable = false, updatable = false)
@JoinColumn(name = "repair_id", insertable = false, updatable = false)
This was the culprit