I have use case in JPA where I need to increase the quantity or update the existing row with quantity on duplicate insertion of a primary key.
@Table(name = "order_line_exception")
@IdClass(OrderLineExceptionKey.class)
public class OrderLineException
@Id
@Column(name = "order_id")
private long orderId;
@Id
@Column(name = "gtin_nbr")
private String gtinNbr;
@Id
@Column(name = "order_line_nbr")
private short orderLineNbr;
@Id
@Column(name = "exception_code")
private short exceptionCode;
@Column(name = "exception_qty")
private int exceptionQty;
}````
increase exceptionQty if same primary key repeated