hibernate-orm icon indicating copy to clipboard operation
hibernate-orm copied to clipboard

Reproducer for incorrect function argument domain type

Open jwgmeligmeyling opened this issue 2 years ago • 2 comments

Reproducer that argument type is not properly resolvable from SqmFunction return type resolvers.

Test fails with:

Unexpected type ==> expected: <org.hibernate.type.CustomType> but was: <org.hibernate.metamodel.model.domain.internal.BasicTypeImpl>
Expected :org.hibernate.type.CustomType
Actual   :org.hibernate.metamodel.model.domain.internal.BasicTypeImpl

jwgmeligmeyling avatar Mar 16 '23 12:03 jwgmeligmeyling

Thanks for your pull request!

This pull request does not follow the contribution rules. Could you have a look?

❌ All commit messages should start with a JIRA issue key matching pattern HHH-\d+     ↳ Offending commits: [782b4878e6b527fd09813dc702c5f6afb1c02e6b]

› This message was automatically generated.

A "work around" seems to be to get the entity name and attribute name from the SqmTypedNode and look it up in the Metamodel, although this requires access to the SessionFactory which is only accessible through a deprecated method:

typeConfiguration.getSessionFactory().getMappingMetamodel()
     .getEntityDescriptor(((SqmRoot) ((SqmBasicValuedSimplePath) arguments.get(0)).getLhs()).getEntityName())
    .getPropertyType(((SqmBasicValuedSimplePath) arguments.get(0)).getNavigablePath().getLocalName());
							

jwgmeligmeyling avatar Mar 16 '23 12:03 jwgmeligmeyling