-
Notifications
You must be signed in to change notification settings - Fork 75
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
Allow to retrieve a proxy of Statement#getResultSet during boolean PreparedStatement.execute()
#114
Comments
boolean PreparedStatement.execute()
/**
* Does this dialect fully support returning arbitrary generated column values
* after execution of an {@code insert} statement, using native SQL syntax?
* <p>
* Support for identity columns is insufficient here, we require something like:
* <ol>
* <li>{@code insert ... returning ...}
* <li>{@code select from final table (insert ... )}
* </ol>
*
* @return {@code true} if {@link org.hibernate.id.insert.InsertReturningDelegate}
* works for any sort of primary key column (not just identity columns), or
* {@code false} if {@code InsertReturningDelegate} does not work, or only
* works for specialized identity/"autoincrement" columns
*
* @see org.hibernate.id.insert.InsertReturningDelegate
*
* @since 6.2
*/
public boolean supportsInsertReturning() {
return false;
} Looks like this is the feature that needs support. For PostgresDialect, it returns true. |
Hi @reda-alaoui, Thanks for the report. So, if I understand correctly, when inserting a record to Postgres with new Hibernate, it issues a query like Since the I’m thinking how to address this, and one potential approach could be:
|
Hi @ttddyy , |
Ah, no. They are not separate options, just one option. So, it needs a code change in datasource-proxy. |
By making `ResultSetProxyLogicFactory` aware of queries; so that, it can generate `ResultSetProxyLogic` based on the queries. Relates to #114
Hi @reda-alaoui I've created a poc for this issue. The datasource-proxy side change is in The main part is DynamicResultSetProxyLogicFactory, which determines the proxy based on the executing query. When the query contains When you get a chance, can you check whether this could work for your usage in postgres returning queries? |
Hibernate recently changed the way it fetches
insert
generated keys for PostgresSQL. Instead of relying onStatement#getGeneratedKeys()
andStatement#RETURN_GENERATED_KEYS
, it usesStatement#getResultSet
this way :Because of this, we need a way to retrieve a Repeatable
Statement#getResultSet
cached duringboolean PreparedStatement.execute()
.The text was updated successfully, but these errors were encountered: