最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

spring - How to add an auto increment none id field in hibernate - Stack Overflow

programmeradmin2浏览0评论

I'm having issues adding a non id auto increment field in my orders table, the order number field should be handled by the database auto increment feature, I'm using postgres, the only catch is my field isn't the id of the table which gives me this error

is annotated @GeneratedValue but is not part of an identifier

My code

data class Order(
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    val id: UUID? = null,
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "order_number", unique = true, nullable = false, updatable = false, insertable = false)
    val orderNumber: Long? = null,
发布评论

评论列表(0)

  1. 暂无评论