最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin6PV0评论

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,
Post a comment

comment list (0)

  1. No comments so far