Skip to content
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

Compatibility of ImmutableType with custom functions and typed paramaters #430

Open
jwgmeligmeyling opened this issue Apr 18, 2022 · 2 comments

Comments

@jwgmeligmeyling
Copy link
Contributor

jwgmeligmeyling commented Apr 18, 2022

  • metadataBuilder.applySqlFunction requires a FunctionReturnTypeResolver which in turns require types to extend from ReturnableType
  • metadataBuilder.applySqlFunction requires a FunctionArgumentTypeResolver which in turns require types to extend from MappingModelExpressible<?>, like for example BasicValuedMapping is.
  • TypedParameterValue requires a BindableType, like for example SqmExpressible is.

I think in order to support custom functions and typed parameters the following signature changes need to be made:

  • Make MutableType additionally extend from ReturnableType<T>. This only allows the introduction of getPersistenceType and getJavaType at MutableType level.
  • Make ImmutableType extend from UserType<T>, BindableType<T>, SqmExpressible<T>, BasicValuedMapping, ReturnableType<T> instead of MutableType, like MutableType.

Whilst the new type system of Hibernate 6.0 is one of its key features, I am currently not really seeing it. It could well be possible that more changes will be required. At this point we may want to just go for BasicType extensions instead ... The org.hibernate.usertype.UserType hierarchy seems fairly limited in its current abilities.

@vladmihalcea
Copy link
Owner

The problem with BasicType is that users will no longer be able to define the @Type on the entity attribute.

However, we could investigate whether we could provide the user a JsonJavaType and JsonJdbcType which they could use as an alternative to the standard JsonType, and those could address the problems you mentioned.

@jwgmeligmeyling
Copy link
Contributor Author

jwgmeligmeyling commented Mar 16, 2023

We're getting pretty far with this using the CustomType wrapper in Hibernate, but we're currently limited by this limitation in Hibernate: hibernate/hibernate-orm#6258 . I'll keep updating this thread as I make progress with getting custom functions to work with custom types (both as argument and return type of functions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants