Skip to content

Commit

Permalink
[#1949] Workaround signature change in RowTransformers
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed Nov 4, 2024
1 parent f3cafb4 commit 8d9ba68
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public class HibernateExtendedQuerySupport implements ExtendedQuerySupport {
private static final Logger LOG = Logger.getLogger(HibernateExtendedQuerySupport.class.getName());
private static final Constructor<TupleMetadata> TUPLE_METADATA_CONSTRUCTOR_62;
private static final Constructor<TupleMetadata> TUPLE_METADATA_CONSTRUCTOR_63;
private static final RowTransformer ROW_TRANSFORMER_SINGULAR_RETURN;
private static final RowTransformer ROW_TRANSFORMER_STANDARD;

static {
Constructor<TupleMetadata> constructor62 = null;
Expand All @@ -165,6 +167,12 @@ public class HibernateExtendedQuerySupport implements ExtendedQuerySupport {
}
TUPLE_METADATA_CONSTRUCTOR_62 = constructor62;
TUPLE_METADATA_CONSTRUCTOR_63 = constructor63;
try {
ROW_TRANSFORMER_SINGULAR_RETURN = (RowTransformer) RowTransformerSingularReturnImpl.class.getField("INSTANCE" ).get(null);
ROW_TRANSFORMER_STANDARD = (RowTransformer) RowTransformerStandardImpl.class.getField("INSTANCE").get(null);
} catch (NoSuchFieldException | IllegalAccessException ex) {
throw new RuntimeException("Could not find standard row transformers. Please report your version of hibernate so we can provide support for it!", ex);
}
}

private final HibernateAccess hibernateAccess;
Expand Down Expand Up @@ -724,7 +732,7 @@ private <R> RowTransformer<R> determineRowTransformer(
if (queryOptions.getTupleTransformer() != null) {
return makeRowTransformerTupleTransformerAdapter(sqm, queryOptions);
} else {
return RowTransformerStandardImpl.instance();
return ROW_TRANSFORMER_STANDARD;
}
}

Expand Down Expand Up @@ -753,7 +761,7 @@ private <R> RowTransformer<R> determineRowTransformer(
} else if (selections.size() > 1) {
throw new IllegalQueryOperationException("Query defined multiple selections, return cannot be typed (other that Object[] or Tuple)");
} else {
return RowTransformerSingularReturnImpl.instance();
return ROW_TRANSFORMER_SINGULAR_RETURN;
}
}

Expand Down Expand Up @@ -1147,7 +1155,7 @@ public boolean hasQueryExecutionToBeAddedToStatistics() {
realJdbcSelect,
jdbcParameterBindings,
hibernateAccess.wrapExecutionContext(executionContext, dbmsDialect, returningColumns, returningColumnTypes, returningResult),
RowTransformerStandardImpl.instance(),
ROW_TRANSFORMER_STANDARD,
ListResultsConsumer.UniqueSemantic.FILTER
);
} catch (HibernateException e) {
Expand Down

0 comments on commit 8d9ba68

Please sign in to comment.