Skip to content

Spring 6.x compatability with Hibernate 5.6.x EntityManager #33129

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

Closed
sjaks opened this issue Jul 1, 2024 · 3 comments
Closed

Spring 6.x compatability with Hibernate 5.6.x EntityManager #33129

sjaks opened this issue Jul 1, 2024 · 3 comments
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: invalid An issue that we don't feel is valid

Comments

@sjaks
Copy link

sjaks commented Jul 1, 2024

When attempting to use Hibernate 5.6 in an application that was migrated to Spring 6, I get an exception:

incompatible types: java.lang.Class<javax.persistence.EntityManagerFactory> cannot be converted to java.lang.Class<? extends jakarta.persistence.EntityManagerFactory>

We have tried to use hibernate-core-jakarta as stated in the issue #31039. HibernateJpaVendorAdapter is used in the application and the issue seems to be where entityManagerFactory is passed to JpaTransactionManager:

@Bean
public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
    return new JpaTransactionManager(entityManagerFactory);
}

Since Spring 6, the jakarta namespace is used instead of javax and here the new jakarta classes are expected. Shouldn't hibernate-core-jakarta provide a way to use, for example, Hibernate 5.6 but with jakarta?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 1, 2024
@snicoll
Copy link
Member

snicoll commented Jul 1, 2024

Unfortunately, there's nothing actionable. You've found out about hibernate-core-jakarta but you're providing a partial error message with no context and no way for us to know what you're doing.

If you want support, please share a small sample we can run ourselves that reproduces the issue. However, I suspect you'll find out the problem in your arrangement in doing so. If you do, please report back so that we can update this issue.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Jul 1, 2024
@jhoeller
Copy link
Contributor

jhoeller commented Jul 1, 2024

We compile and run our core spring-orm integration tests against hibernate-core-jakarta 5.6.15, so this should definitely be compatible. With such an exception message as shown above, you still got some precompiled classes using javax.persistence.EntityManagerFactory around; please double-check your build setup to consistently use Jakarta Persistence 3.0 compatible artifacts there.

@jhoeller jhoeller added the in: data Issues in data modules (jdbc, orm, oxm, tx) label Jul 1, 2024
@sjaks
Copy link
Author

sjaks commented Jul 2, 2024

I can now confirm that JpaTransactionManager accepts the given entityManagerFactory coming from Jakarta.

The issue was caused by having both hibernate-core and hibernate-core-jakarta in the dependencies.

@sjaks sjaks closed this as completed Jul 2, 2024
@bclozel bclozel added status: invalid An issue that we don't feel is valid and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged or decided on labels Jul 2, 2024
@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

5 participants