Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Many DBs have some kind of RETURNING clause that allows to specify which columns of inserted/updated/deleted rows should be returned from a DML statement. We could also use this mechanism internally for fetching generated values after entity inserts/updates instead of doing full fetches.

I propose a syntax extension for DML statements: ('returning' expression (',' expression)*)?

Emulating this feature, although not easy, should be possible. We'd have to use our multi-table facilities for that purpose, which will first insert ids of entities to modify into a temporary table, then run the DML and finally run a select statement for the returning clause based on the data from the temporary table.

You must be logged in to vote

Replies: 2 comments · 1 reply

Comment options

We could also use this mechanism internally for fetching generated values after entity inserts/updates instead of doing full fetches

We already do this, don't we?

You must be logged in to vote
1 reply
@beikov
Comment options

beikov Aug 8, 2023
Maintainer Author

We currently always run a dedicated select statement for generated properties (see GeneratedValuesProcessor), which we could already avoid, because the SQL AST already models this returning clause. The note about using this internally was only tangential though. My main motivation for this discussion is to discuss support for this clause in HQL/Criteria.

Comment options

https://hibernate.atlassian.net/browse/HHH-19405

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.