Skip to content

use 'select id from final table' to retrieve generated key #4569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

gavinking
Copy link
Member

see #4524 (comment)

Is this correct @froque and @katzyn?

Does it actually work?


@Override
public String appendIdentitySelectToInsert(String insertString) {
return "select id from final table (" + insertString + ")";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I explored something like this. This does not work if the column is not named id

19:03:24.089 [Time-limited test] ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Column "ID" not found; SQL statement:
select id from final table (insert into Event (id2, active, createdOn) values (default, ?, ?)) [42122-202]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK thanks.

@gavinking gavinking closed this Jan 4, 2022
@gavinking gavinking deleted the h2_final_table branch June 15, 2023 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants