dimas-b commented on code in PR #3334:
URL: https://github.com/apache/polaris/pull/3334#discussion_r2651457614
##########
persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcBasePersistenceImpl.java:
##########
@@ -431,15 +448,34 @@ public PolarisBaseEntity lookupEntityByName(
name,
"realm_id",
realmId);
- return getPolarisBaseEntity(
+ QueryGenerator.PreparedQuery query =
QueryGenerator.generateSelectQuery(
- ModelEntity.getAllColumnNames(schemaVersion),
ModelEntity.TABLE_NAME, params));
+ ModelEntity.getAllColumnNames(schemaVersion),
ModelEntity.TABLE_NAME, params);
+ return getPolarisBaseEntity(query, connection);
}
@Nullable
private PolarisBaseEntity getPolarisBaseEntity(QueryGenerator.PreparedQuery
query) {
+ return getPolarisBaseEntity(query, null);
+ }
+
+ /**
+ * Execute entity lookup, optionally using an existing connection to
maintain transaction
+ * consistency.
+ *
+ * @param query the prepared query to execute
+ * @param connection optional connection to reuse; if null, a new connection
will be obtained
+ * @return the entity if found, null otherwise
+ */
+ @Nullable
+ private PolarisBaseEntity getPolarisBaseEntity(
+ QueryGenerator.PreparedQuery query, @Nullable Connection connection) {
try {
- var results = datasourceOperations.executeSelect(query, new
ModelEntity(schemaVersion));
+ List<PolarisBaseEntity> results =
+ connection != null
Review Comment:
It looks like `connection` is `null` when called from `writeEntity`... Does
that call path not have the same issue (reading in another transaction) that
this PR is trying to fix?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]