Skip to content

Conversation

@gtoison
Copy link
Contributor

@gtoison gtoison commented Sep 9, 2021

A simple unit test illustrating issue HHH-14820 : since Hibernate ORM 6 the custom NamedEnumUserType is only instantiated once (while there aretwo enums configured with this type).

When trying to execute a query that NamedEnumUserType has the last enum class and Enum.valueOf(...) fails.

The test is currently marked with @Ignore so it needs to be removed to get a failing result.

See the JIRA HHH-14820 issue

A simple unit test illustrating issue HHH-14820 : since Hibernate ORM 6
the custom NamedEnumUserType is only instantiated once (while there are
two enums configured with this type)
@gtoison gtoison changed the title HHH-14820 Reproducer HHH-14820 Reproducer - Customized EnumType not working with hbm mapping in Hibernate 6 Sep 9, 2021
@beikov beikov self-assigned this Sep 10, 2021
@beikov
Copy link
Member

beikov commented Sep 10, 2021

Thanks a lot for the test case. I'll look into it ASAP.

@sebersole sebersole self-assigned this Sep 30, 2021
@sebersole
Copy link
Member

sebersole commented Sep 30, 2021

I'm curious what actually fails for you here. The test passes for me rebased on top of current 6.0 branch.

@gtoison
Copy link
Contributor Author

gtoison commented Sep 30, 2021

Did you remove the @Ignore ?
I was not sure what was the right way to add a failing unit test

@sebersole
Copy link
Member

Did you remove the @Ignore ? I was not sure what was the right way to add a failing unit test

Probably you meant to execute the query...

@sebersole
Copy link
Member

Ok, that was it. You probably removed the execution at some point

@sebersole
Copy link
Member

BTW, have a fix already. Running the full tests and I'll push for you to try

@gtoison
Copy link
Contributor Author

gtoison commented Sep 30, 2021

Sorry that was not super clear, I tried again with the latest version of the wip/6.0 branch and test failed with this error:

> Task :hibernate-core:test

NamedEnumUserTypeTest > testNamedEnumUserType FAILED
    jakarta.persistence.PersistenceException at ExceptionConverterImpl.java:167
        Caused by: org.hibernate.HibernateException at JdbcValuesResultSetImpl.java:312
            Caused by: java.lang.IllegalArgumentException at Enum.java:238

It's great to hear that fix is coming up, thank you very much for looking into it!

@sebersole
Copy link
Member

No idea. But the test does not fail until I actually executed the query. And in fact your stacktrace implies the same

@hibernate-github-bot
Copy link

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: [ad0dc29, 2c1f33a]

› This message was automatically generated.

@gtoison
Copy link
Contributor Author

gtoison commented Sep 30, 2021

Yes sorry I was trying to say that the @Ignore annotation needs to be removed
In some projects the etiquette for submitting a failing unit test is to commit it disabled so you don't break the build.

I've removed it in a new commit for the sake of clarity. Sorry for the noise!

@sebersole
Copy link
Member

But this is your test method:

		doInHibernate( this::sessionFactory, s -> {
			s.createQuery( "from Person p", Person.class );
		} );

The query is not executed. In other words I only got this to fail when I changed that to

		doInHibernate( this::sessionFactory, s -> {
			s.createQuery( "from Person p", Person.class ).list();
		} );

@sebersole
Copy link
Member

Fixed - c799f85

@sebersole sebersole closed this Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants