Skip to content

HHH-15862 Support basic array values in aggregate components #7577

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

Merged
merged 1 commit into from
May 7, 2024

Conversation

beikov
Copy link
Member

@beikov beikov commented Nov 27, 2023

Some notes on changes that we might want to discuss:

  • Introduction of SqlTypedJdbcType to store descriptor by SQL type name in JdbcTypeRegistry
    => Allow resolving the correct type for native query results e.g. named array etc.
  • Make UserDefinedType an interface with impls: UserDefinedObjectType and UserDefinedArrayType
    => Needed to understand dependencies between named array types and the object type during DDL generation
    => Small breakage? some methods in e.g. ColumnOrderingStrategy, Namespace
  • Argument type changes in AggregateSupport
    => Should be fine since it's incubating
  • Convenience method in PropertyData getClassOrPluralElement
    => Is probably going to cause trouble with ORM 7 rebase?
  • NestedColumnReference is built for EmbeddableFunctionTableReference in SqlExpressionResolver#resolveSqlExpression
    => Model a column with a base expression e.g. array_get(...).columnName
  • EmbeddableAggregateJavaType recommends UnresolvedStructJdbcType retaining the structName, if no existing descriptor exists
    => UnresolvedStructJdbcType is a "temporary" descriptor. The BasicType with the proper JdbcType is registered when EmbeddableMappingTypeImpl is constructed
    => Needed for the bootstrap process. StructJdbcType implementations depend on EmbeddableMappingType, but need a temporary JdbcType for attributes until EmbeddableMappingTypeImpl is constructed
    => This in turn requires a JdbcMapping overriding mechanism in InferredBasicValueResolution via #updatedType
    => When EmbeddableMappingTypeImpl is built, the correct StructJdbcType is built, as well as BasicType, which needs is then updated in the Resolution
  • MappingModelCreationHelper.resolveAggregateColumnBasicType builds an EmbeddableMappingTypeImpl for the array component with a fake EmbeddableValuedModelPart
    => Called when basic attributes are built: AbstractEntityPersister, AbstractEmbeddableMapping, EmbeddableMappingTypeImpl
  • ValueBinder now exposes #getBindValue
    => Necessary to allow saving structs with nested arrays etc.

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

Class<?> javaTypeClass = jdbcMapping.getJavaTypeDescriptor().getJavaTypeClass();
if ( javaTypeClass == Boolean.class ) {
// BooleanJavaType has this as an implicit conversion
return Integer.parseInt( string, start, end, 10 ) == 1;

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException

Potential uncaught 'java.lang.NumberFormatException'.
return Integer.parseInt( string, start, end, 10 ) == 1;
}
if ( javaTypeClass.isEnum() ) {
return javaTypeClass.getEnumConstants()[Integer.parseInt( string, start, end, 10 )];

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException

Potential uncaught 'java.lang.NumberFormatException'.
@beikov beikov force-pushed the HHH-15862 branch 2 times, most recently from 598b668 to 5faaa37 Compare November 28, 2023 16:59
Comment on lines +74 to +76
throw new SemanticException(
"Oracle array_agg emulation requires a basic plural return type, but resolved return type was: " + returnType
);

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation

Invoking [SemanticException.SemanticException](1) should be avoided because it has been deprecated.
Comment on lines 85 to 96
return resolveFunctionReturnType(
impliedType,
converter == null ? () -> null : converter::resolveFunctionImpliedReturnType,
arguments,
typeConfiguration
);

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation

Invoking [FunctionReturnTypeResolver.resolveFunctionReturnType](1) should be avoided because it has been deprecated.
@beikov beikov force-pushed the HHH-15862 branch 5 times, most recently from 84a17ac to 557bc01 Compare November 30, 2023 22:14
@beikov beikov added the 6.5 label Dec 1, 2023
@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Apr 10, 2024

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

@@ -125,4 +161,8 @@

return new String[] { buf.toString() };
}

public String[] getSqlDropStrings(UserDefinedArrayType userDefinedType, Metadata metadata, SqlStringGenerationContext context) {

Check notice

Code scanning / CodeQL

Useless parameter

The parameter 'metadata' is never used.
}
}

public String[] getSqlDropStrings(UserDefinedObjectType userDefinedType, Metadata metadata, SqlStringGenerationContext context) {

Check notice

Code scanning / CodeQL

Useless parameter

The parameter 'metadata' is never used.
}

@Override
public boolean equals(Object object) {

Check notice

Code scanning / CodeQL

Confusing overloading of methods

Method AbstractUserDefinedType.equals(..) could be confused with overloaded method [equals](1), since dispatch depends on static types.
@beikov beikov force-pushed the HHH-15862 branch 2 times, most recently from 6fe0458 to 879b701 Compare May 3, 2024 16:21
@beikov beikov marked this pull request as ready for review May 3, 2024 16:21
@beikov beikov merged commit d1b30e1 into hibernate:main May 7, 2024
@beikov beikov deleted the HHH-15862 branch May 22, 2024 11:33
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.

1 participant