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

Support for hibernate 6.2 #495

Closed
razubuddy opened this issue May 24, 2023 · 15 comments
Closed

Support for hibernate 6.2 #495

razubuddy opened this issue May 24, 2023 · 15 comments
Assignees

Comments

@razubuddy
Copy link

Hibernate 6.2 changed base class for generators, now it is org.hibernate.id.Generator instead of org.hibernate.id.IdentifierGenerator. This change generates ClassCastException in current imnplementation:

java.lang.ClassCastException: class org.hibernate.id.IdentityGenerator cannot be cast to class org.hibernate.id.IdentifierGenerator (org.hibernate.id.IdentityGenerator and org.hibernate.id.IdentifierGenerator are in unnamed module of loader 'app')
        at org.hibernate.mapping.KeyValue.createIdentifierGenerator(KeyValue.java:58)
        at liquibase.ext.hibernate.snapshot.TableSnapshotGenerator.addTo(TableSnapshotGenerator.java:84)
        at liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator.snapshot(HibernateSnapshotGenerator.java:82)
        at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:49)
        at liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator.snapshot(HibernateSnapshotGenerator.java:74)
        at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:49)
        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:313)
        at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:106)
        at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:59)
        at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:34)
        at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:214)
        at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:187)
        at liquibase.command.core.DiffCommandStep.generateDatabaseShapshot(DiffCommandStep.java:203)
        at liquibase.command.core.DiffCommandStep.createReferenceSnapshot(DiffCommandStep.java:190)
        at liquibase.command.core.DiffCommandStep.createDiffResult(DiffCommandStep.java:113)
        at liquibase.command.core.DiffCommandStep.run(DiffCommandStep.java:89)
        at liquibase.command.CommandScope.execute(CommandScope.java:212)
        ...
@Bert-R
Copy link

Bert-R commented Jun 1, 2023

Relates to #493

@bazsoja
Copy link

bazsoja commented Jun 26, 2023

We have the same problem. Is there any update on this?

@Bert-R
Copy link

Bert-R commented Jun 27, 2023

I was hoping this would be gone with 4.23.0, but unfortunately it's still there

@bazsoja
Copy link

bazsoja commented Jun 28, 2023

Thank you for the feedback!

@xintellion
Copy link

xintellion commented Jul 4, 2023

The release notes for 4.23.0 say it was included but it still uses hibernate 6.1.* any plans for 4.23.1?

@matthiasstrauch
Copy link

Running 4.23.0 and having the same issue with the @UuidGenerator annotation:
liquibase.exception.CommandExecutionException: java.lang.ClassCastException: class org.hibernate.id.uuid.UuidGenerator cannot be cast to class org.hibernate.id.IdentifierGenerator (org.hibernate.id.uuid.UuidGenerator and org.hibernate.id.IdentifierGenerator are in unnamed module of loader 'app')

@Bert-R
Copy link

Bert-R commented Jul 8, 2023

I've been debugging this and in my view, it's an issue in Hibernate. I've reported it as HHH-16912.

@Bert-R
Copy link

Bert-R commented Jul 19, 2023

@nvoxland @filipelautert Can someone from the Liquibase Hibernate team look at the feedback that the Hibernate team provided on HHH-16912?

@filipelautert filipelautert self-assigned this Jul 19, 2023
@filipelautert
Copy link
Collaborator

@Bert-R thanks for the ping. I'll fix the cast on Liquibase side for the next release and will link the PR here so we can get it tested.

@filipelautert
Copy link
Collaborator

PR #508 should fix it - please fell free to test it.

@Bert-R
Copy link

Bert-R commented Jul 19, 2023

@filipelautert Thanks for the very quick follow up!
I don't know how to test it. The procedure described on the PR is based on Maven, but I'm using Gradle.
However, I'm confident that will work, as I implemented the same fix two weeks ago, while debugging the issue. At that time, I didn't dare to create a PR as that would break compatibility with Hibernate 6.0.2 and 6.1.7.

You've removed these from the texting matrix, so you apparently accept breaking that compatibility. In that case, I'd suggest to remove the testing matrix, to prevent manual maintenance effort. Dependabot does not update that value, so you always need to change it manually. That is why the incompatibility of 6.2 could go unnoticed.

@filipelautert
Copy link
Collaborator

Hi - Hibernate 6.2.7.Final has been release and it fixes the problem - we already updated main to use this version. So we will hold the switch to 6.2 API from #508 for a while and imporve it to allow 6.0 and 6.1 compatibility .

@Bert-R
Copy link

Bert-R commented Jul 31, 2023

That makes sense.

The suggestion on HHH-16912 was slightly different from what you implemented:

Now, on the other hand, on the Liquibase side, and please bear with me, because I don’t know anything about that code at all, but it appears that Liquibase only supports TableGenerator, and not SequenceStyleGenerator in table mode, which is a quite usual type of table generation since a long time.

That might be a way to implement a new generator that's compatible with all 6.x versions.

@Bert-R
Copy link

Bert-R commented Aug 17, 2023

The intermediate solution (upgrade to 6.2.7) works for me. Thanks for that!

@filipelautert
Copy link
Collaborator

Thanks for the feedback! I'm still thinking on how to use 6.2 apis breaking backwards compatibility - thus I"m holding #508 a bit.
Anyway this one can be closed as fixed by hibernate/hibernate-orm#7023 🎉

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

No branches or pull requests

6 participants