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

admin2025-04-26  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,
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745649476a312079.html

最新回复(0)