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

Remove warning generated on startup "Type [org.hibernate.type.CustomType@6142b9dd] defined no registration keys; ignoring" #427

Closed
Bas83 opened this issue Apr 14, 2022 · 6 comments
Assignees
Labels
Milestone

Comments

@Bas83
Copy link

Bas83 commented Apr 14, 2022

In our Spring Boot application (2.6.6), after updating Hibernate-Types-55 from 2.14.1 to 2.15.1 we are getting the following warning on startup:

Type [org.hibernate.type.CustomType@6142b9dd] defined no registration keys; ignoring

On the logger org.hibernate.type.BasicTypeRegistry

However, we're not creating any custom types, we're only using DecimalArrayType which indeed doesn't seem to have these registration keys.

We have this definition on 2 Entity classes:

@TypeDefs({
    @TypeDef(
        name = "big-decimal-array",
        typeClass = DecimalArrayType.class
    )
})

And then also a custom postgres dialect:

import com.vladmihalcea.hibernate.type.array.DecimalArrayType;
import java.sql.Types;
import org.hibernate.dialect.PostgreSQL95Dialect;

public class PostgreSQL95CustomDialect extends PostgreSQL95Dialect {

    public PostgreSQL95CustomDialect() {
        super();
        // this is not super extendible because now ALL arrays in custom queries are treated as BigDecimal arrays.
        this.registerHibernateType(Types.ARRAY, DecimalArrayType.class.getName());
    }
}

Are we doing anything wrong or is this an issue in the library?

@Bas83
Copy link
Author

Bas83 commented Apr 14, 2022

I just put a breakpoint on the line that actually throws the exception and it seems to be about the type com.vladmihalcea.hibernate.type.basic.NullableCharacterType

@vladmihalcea
Copy link
Owner

It could be the HibernateTypesContributors that auto-registers some Types, or it could be something else.

You can debug to see why this warning is generated and see whether the call originates in the HibernateTypesContributors. I will need as much context as possible so that I can understand why it's being generated.

@Bas83
Copy link
Author

Bas83 commented Apr 14, 2022

I just debugged, in the previous version this type com.vladmihalcea.hibernate.type.basic.NullableCharacterType was never registered in the BasicTypeRegistry, but now it is. Thus causing the warning there.

It is indeed being registered in the HibernateTypesContributors at the line typeContributions.contributeType(NullableCharacterType.INSTANCE, new String[0]);

(and then through MetadataBuildingProcess.contributeType at line 356)

@vladmihalcea
Copy link
Owner

vladmihalcea commented Apr 14, 2022

Indeed, the issue can be replicated with the existing test cases, so I'll provide a fix for it when I have some time. In the meanwhile, you can simply ignore it as it won't affect the functionality of your application.

@vladmihalcea
Copy link
Owner

The solution requires the HibernateTypesContributor to provide the registration key.

So instead of:

typeContributions.contributeType(NullableCharacterType.INSTANCE);

it should use something like this:

typeContributions.contributeType(NullableCharacterType.INSTANCE, NullableCharacterType.INSTANCE.getName());

But, this is not just for the NullableCharacterType. All Types that implement UserType require this change.

@vladmihalcea vladmihalcea changed the title Warning on startup "Type [org.hibernate.type.CustomType@6142b9dd] defined no registration keys; ignoring" after updating Hibernate-Types-55 from 2.14.1 to 2.15.1 Remove warning generated on startup "Type [org.hibernate.type.CustomType@6142b9dd] defined no registration keys; ignoring" after updating Hibernate-Types-55 from 2.14.1 to 2.15.1 Apr 14, 2022
@vladmihalcea vladmihalcea changed the title Remove warning generated on startup "Type [org.hibernate.type.CustomType@6142b9dd] defined no registration keys; ignoring" after updating Hibernate-Types-55 from 2.14.1 to 2.15.1 Remove warning generated on startup "Type [org.hibernate.type.CustomType@6142b9dd] defined no registration keys; ignoring" Apr 14, 2022
vladmihalcea added a commit that referenced this issue Apr 14, 2022
…ype@6142b9dd] defined no registration keys; ignoring" #427
@vladmihalcea vladmihalcea self-assigned this Apr 14, 2022
@vladmihalcea vladmihalcea added this to the 2.16.1 milestone Apr 14, 2022
@vladmihalcea
Copy link
Owner

Fixed.

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

No branches or pull requests

2 participants