Hibernate Id Sequence Resulting null

  • I have one Table in postgresql database with two id Sequence.

    @JsonProperty("id") @Column(name = "id", nullable = false,unique=true) @Id @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "order_seq_gen") @SequenceGenerator(name = "order_seq_gen", sequenceName ="order_id_seq")

    private Integer id;
    @JsonProperty("state")
    private String state;
    
    @JsonProperty("order_id")
    @Column(name="order_id", nullable=false, unique=true, insertable = false,    updatable = true,
            columnDefinition = "BIGINT DEFAULT nextval('order_idgen_seq')"
    )
    @GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "order_seq_gen")
    @SequenceGenerator(name = "order_seq_gen", sequenceName ="order_idgen_seq")
    private Integer orderId;
    
  • This is my pojo.

  • My issue with the orderId, if I call my CRUD Repository save it is creating new record with those sequence starting values,

  • while returning the object orderId is resulting null but it is there in my table.

  • I have checked with the pojo and column mapping everything is fine but I'm not getting where it went wrong.

  • Another id sequence is returning without any issue but while coming to orderId it is resulting always null.

  • Please help me to solve this, Thankful to them.

  • 链接地址: http://www.djcxy.com/p/90896.html

    上一篇: 配置Sqlite3进行休眠

    下一篇: 休眠ID序列结果为空