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