Skip to content

Triggers/autogenerated values for Partial keys in Hibernate ORM #45865

Answered by mbladel
LarsSven asked this question in Q&A
Discussion options

You must be logged in to vote

So there's a couple of things going on here:

  1. You're using @GeneratedValue, which has a totally different meaning from @Generated. The first annotation uses a specific on-execution generator that, if no explicit value is specified, defaults to GenerationType.AUTO which will in turn choose a suited automatic identifier generation strategy for your database. The @Generated annotation instead implies the value is created on the database-side and that Hibernate should retrieve it after mutating the table.
  2. You're mixing on-execution generated values with non generated, that is not supported in Hibernate ORM. That is why when you were trying to use @Generated you got the error Property of on-ex…

Replies: 2 comments 13 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
13 replies
@LarsSven
Comment options

@mbladel
Comment options

mbladel Jan 28, 2025
Collaborator

@LarsSven
Comment options

@mbladel
Comment options

mbladel Jan 28, 2025
Collaborator

Answer selected by LarsSven
@LarsSven
Comment options

@mbladel
Comment options

mbladel Jan 28, 2025
Collaborator

@LarsSven
Comment options

@mbladel
Comment options

mbladel Jan 28, 2025
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants