Alternative to DynamicParameterizedType.ENTITY in setParameters?

Since DynamicParameterizedType is deprecated for removal since 7.0 i am wondering if there is an alternative to how i was able to get the Class and Property names in setParameters?

So before i was able to do this:

public class HibernateApiIdType implements UserType<ApiId>, EnhancedUserType<ApiId>, DynamicParameterizedType {

    private String propertyName;
    private String entityName;

    @Override
    public void setParameterValues(Properties parameters) {
        this.propertyName = (String) parameters.get(DynamicParameterizedType.PROPERTY);
        this.entityName = (String) parameters.get(DynamicParameterizedType.ENTITY);
    }
    . . . .
}

This had the advantage that i did not have to pass the class and property name in the annotation myself, which was especially useful when “wrapping” the @Type annotation in another custom annotation.

When using ParameterizedType, which is mentioned as a replacement, setParameters is empty. This is because the BasicValueBinder has this code:

		if ( explicitCustomType != null
				&& DynamicParameterizedType.class.isAssignableFrom( explicitCustomType ) ) {
			basicValue.setTypeParameters( createDynamicParameterizedTypeParameters() );
		}

Is there any way to get this functionality back while using ParameterizedType, without passing in the parameters myself? Especially since passing both class and property name feels really superfluous.

Thanks!

I don’t think there are any immediate plans to remove DynamicParameterizedType, so you can still use it. If you care about this functionality, I would suggest you open a Jira issue to request a replacement feature that is more type-safe.

Thanks for your answer. I’ve opened a improvement-issue to maybe discuss this further: Jira

1 Like