Home > Mobile >  How to generate id when there are composite keys in entity Spring Boot?
How to generate id when there are composite keys in entity Spring Boot?

Time:11-19

How to generate id when there are composite keys in entity spring boot, I have make composite primary key using IdClass but it don't go well when I try to insert generated value from Spring Boot

@Entity
@DynamicUpdate
@DynamicInsert
@Table(name = "tm_trx_flow")
@IdClass(TmTrxFlowSerializable.class)
public class TmTrxFlow {
    @Id
    @Column(name ="tm_trx_procedure_id")
    private Integer tmTrxProcedureId;
    
    @Id     
    @SequenceGenerator(name = "some_seq", sequenceName = "empid_seq")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "some_seq")
    @Column(name="tm_trx_flow_id")
    private Integer tmTrxFlowId;
    
}

CodePudding user response:

primary key (composite keys) cannot auto generated.

  • Related