Using Statement.RETURN_GENERATED_KEYS for fetching generated values

On every row insert Hibernate issues a select statement to fetch database generated values. I am curious about whether or not Hibernate can or does make use of Statement.RETURN_GENERATED_KEYS or similar returning * construct (wherever supported) to do away with issuing an additional query for fetching generated values.

As of Hibernate ORM 6.5, this is now supported i.e. Hibernate ORM will make use of the returning clause.

1 Like