-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 #2423
Comments
The current state of affairs can be found in
|
Actually, it looks like the |
Other issues currently found (updated continuously):
Related but not crucial:
|
Assigning Jens to investigate the impact of the changes regarding |
Just to note, The final version of Hibernate 6.0 is released by now. |
It's not exact, but I think you can change it like this 🤔 : BindableType<?> bindableType = entityManager.getEntityManagerFactory()
.unwrap(SessionFactoryImplementor.class)
.resolveParameterBindType(parameter.getType());
new TypedParameterValue(bindableType, null); |
I think this may be what you are looking for: class HibernateJpaParametersParameterAccessor extends JpaParametersParameterAccessor {
private final BasicTypeRegistry typeHelper;
/**
* Creates a new {@link ParametersParameterAccessor}.
*
* @param parameters must not be {@literal null}.
* @param values must not be {@literal null}.
* @param em must not be {@literal null}.
*/
HibernateJpaParametersParameterAccessor(Parameters<?, ?> parameters, Object[] values, EntityManager em) {
super(parameters, values);
Session session = em.unwrap(Session.class);
SessionFactoryImplementor sessionFactory = session.getSessionFactory().unwrap(SessionFactoryImplementor.class);
typeHelper = sessionFactory.getTypeConfiguration().getBasicTypeRegistry();
}
@Override
public Object getValue(Parameter parameter) {
Object value = super.getValue(parameter.getIndex());
if (value != null) {
return value;
}
var type = typeHelper.getRegisteredType(parameter.getType());
if (type == null) {
return null;
}
return new TypedParameterValue<>(type, null);
}
} |
After the releases of 6.0 and 6.0.1 Final we run into a couple of new issues:
|
Turns out, checkbox two above is valid as we need to load the entities first to remove them individually as we want to trigger lifecycle callbacks. Scratching that. The We now still run into a StackOverflow when trying to apply entity graphs for a many-to-one reference into a self type (
Also, escape characters are rejected when handed in as A final issue for our tests is the fact that implementations of Hibernate's
|
Just FYI, Hibernate-ORM 6.0.2.Final has been released. |
There's even 6.1 😱. |
The last commit is nearly 2 months old. Are there any plans to add support for Hibernate 6 any time soon? |
The ticket is expression of this plan. I guess the actual question is: what part of it is already working and which one isn't. The good news – and likely something that the ticket summary subverts – is, that this generally already works without further adjustments. The Spring RESTBucks project's That said, there indeed are some features of Spring Data JPA that are currently still broken on H6, primarily due to some internal changes made to H6, tiny bugs, etc. This ticket and the according branch covers our entire build being compatible with it, which of course test a wide variety of even rarely used features. That not being entirely ready doesn't necessarily mean H6 doesn't currently work at all. We're still debating what the best way forward is for our users. We will definitely report our findings with the Hibernate team and hope, they release fixes for the bugs we identified quickly. That said, we could polish up and merge what we already have, and thus temporarily even unlock more features working on H6. For that, we'd have to disable some tests and basically live with a few things knowingly broken, and we're uncertain whether that'd cause too much frustration, especially as it drops H5 compatibility, as we need the dependency upgrade to work with API in H6 to be able to step away from API removed in 6. Any community feedback is appreciated. Also, trying the latest available snapshots of Boot and Data JPA with a manual H6 upgrade for non-trivial applications and providing feedback about that would help us tremendously. |
We're planning to move forward with the merge of the feature branch for the upcoming release. There are still a few things to be worked out with the Hibernate team, but the issues we run into seem to be on the tangential spectrum of our feature list. For a preliminary overview, consult the pending changes in the reference documentation. I am currently consulting the Boot team to make sure they're prepared for us switching to Hibernate 6 as well, but if all goes well, this could be in the upcoming M5 release end of next week. |
…ion. For count queries always start with Long instead of the domain type (Hibernate 6 rejects a mismatch between the type the query was originally set up for and the type to be actually selected). For delete queries, do not use the type to be read, but the domain type as we load the individual instances first to make sure we properly fire entity callbacks. Related ticket: #2423.
TypedQuery inspection through its String representations seems to be a bit flaky in Hibernate 6 still [0]. Tweaked the code to extract a query string from a query object to try the new way first but fall back to the old way, as this seems to work under some conditions, too. Adapted the test case in which we could rather inspect the new SqmQuery API for test result verification. Re-bootstrapping the EntityManagerFactory for the same persistence unit causes the second bootstrap to fail als apparently foreign key names are randomized and the second bootstrap doesn't create a new constraint but tries to work with a new name. Tweaked the offending test case to reuse the existing EMF declaration as it actually only tests the qualified wiring into clients. Applying an entity graph is causing a StackOverflow in current Hibernate 6. Filed an issue [1] and disabled the test case for now. Dial back on the flip to use String as parameter type for like expression escape characters as Eclipselink rejects that. The JPA spec chapter 4.2.10 allows both Character and String to be used. Filed [2] with Hibernate to ask for reintroduction of the support for characters and commented out the test cases for now. Deprecated CustomHsqlHibernateJpaVendorAdapter as it's not needed on Hibernate 6 anymore. Rewrote HibernateJpaParametersParameterAccessor to use Hibernate 6 API. Add Hibernate 6 upgrade information to the reference docs. Related ticket: #2423. [0] https://hibernate.atlassian.net/browse/HHH-15389 [1] https://hibernate.atlassian.net/browse/HHH-15391 [2] https://hibernate.atlassian.net/browse/HHH-15392
…te 6. As recommended in [0], we now set up our integration tests verifying the application of entity load graphs using a lazy @manytoone relationship. [0] https://hibernate.atlassian.net/browse/HHH-15391 Related to #2423.
Closing as the upgrade already shipped with 3.0 M5. Note, that there are still some glitches to be ironed out, in particular around named queries support and entity graphs. The recently shipped Hibernate 6.1.2 fixes a couple of things we found during the upgrade, but some of them are still unresolved / were rediscovered. |
I have a strange case when SpringbootTests (spring boot 3) fail with gradle (7.6) but work in Intellij...
|
@steklopod If you think this is a bug please open a new issue, including a reproducer. |
Hello Team, Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaSharedEM_entityManagerFactory': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:377) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:135) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:686) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:512) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1324) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1161) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:365) ~[spring-beans-6.0.2.jar:6.0.2]
... 87 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.sql.ast.tree.from.UnknownTableReferenceException: Unable to determine TableReference (`saloons`) for `tn.cita.app.model.domain.entity.Favourite.customer.favourites.{fk-target}`
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1751) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:365) ~[spring-beans-6.0.2.jar:6.0.2]
... 99 common frames omitted
Caused by: jakarta.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.sql.ast.tree.from.UnknownTableReferenceException: Unable to determine TableReference (`saloons`) for `tn.cita.app.model.domain.entity.Favourite.customer.favourites.{fk-target}`
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:421) ~[spring-orm-6.0.2.jar:6.0.2]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-6.0.2.jar:6.0.2]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) ~[spring-orm-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1797) ~[spring-beans-6.0.2.jar:6.0.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1747) ~[spring-beans-6.0.2.jar:6.0.2]
... 106 common frames omitted
Caused by: org.hibernate.sql.ast.tree.from.UnknownTableReferenceException: Unable to determine TableReference (`saloons`) for `tn.cita.app.model.domain.entity.Favourite.customer.favourites.{fk-target}`
at org.hibernate.sql.ast.tree.from.LazyTableGroup.resolveTableReference(LazyTableGroup.java:256) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.sql.ast.tree.from.DelegatingTableGroup.resolveTableReference(DelegatingTableGroup.java:62) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.metamodel.mapping.internal.SimpleForeignKeyDescriptor.createDomainResult(SimpleForeignKeyDescriptor.java:245) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.metamodel.mapping.internal.SimpleForeignKeyDescriptor.createTargetDomainResult(SimpleForeignKeyDescriptor.java:178) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.metamodel.mapping.internal.PluralAttributeMappingImpl.createDelayedCollectionFetch(PluralAttributeMappingImpl.java:518) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.metamodel.mapping.internal.PluralAttributeMappingImpl.generateFetch(PluralAttributeMappingImpl.java:422) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.sql.results.graph.FetchParent.generateFetchableFetch(FetchParent.java:105) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.loader.ast.internal.LoaderSelectBuilder.lambda$createFetchableBiConsumer$7(LoaderSelectBuilder.java:846) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.loader.ast.internal.LoaderSelectBuilder.visitFetches(LoaderSelectBuilder.java:684) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.loader.ast.internal.LoaderSqlAstCreationState.visitFetches(LoaderSqlAstCreationState.java:118) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.sql.results.graph.AbstractFetchParent.afterInitialize(AbstractFetchParent.java:32) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.sql.results.graph.entity.AbstractEntityResultGraphNode.afterInitialize(AbstractEntityResultGraphNode.java:100) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl.<init>(EntityFetchJoinedImpl.java:54) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping.lambda$generateFetch$0(ToOneAttributeMapping.java:1258) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping.withRegisteredAssociationKeys(ToOneAttributeMapping.java:1503) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping.generateFetch(ToOneAttributeMapping.java:1233) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping.generateFetch(ToOneAttributeMapping.java:107) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.sql.results.graph.FetchParent.generateFetchableFetch(FetchParent.java:105) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.loader.ast.internal.LoaderSelectBuilder.lambda$createFetchableBiConsumer$7(LoaderSelectBuilder.java:846) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.loader.ast.internal.LoaderSelectBuilder.visitFetches(LoaderSelectBuilder.java:684) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.loader.ast.internal.LoaderSqlAstCreationState.visitFetches(LoaderSqlAstCreationState.java:118) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.sql.results.graph.AbstractFetchParent.afterInitialize(AbstractFetchParent.java:32) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.sql.results.graph.entity.AbstractEntityResultGraphNode.afterInitialize(AbstractEntityResultGraphNode.java:100) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.createDomainResult(AbstractEntityPersister.java:1289) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.loader.ast.internal.LoaderSelectBuilder.generateSelect(LoaderSelectBuilder.java:450) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.loader.ast.internal.LoaderSelectBuilder.createSelect(LoaderSelectBuilder.java:177) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.loader.ast.internal.SingleIdEntityLoaderStandardImpl.createLoadPlan(SingleIdEntityLoaderStandardImpl.java:180) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.loader.ast.internal.SingleIdEntityLoaderStandardImpl.prepare(SingleIdEntityLoaderStandardImpl.java:54) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.prepareLoader(AbstractEntityPersister.java:4286) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.postInstantiate(AbstractEntityPersister.java:4278) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.finishInitialization(MappingMetamodelImpl.java:236) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.metamodel.internal.RuntimeMetamodelsImpl.finishInitialization(RuntimeMetamodelsImpl.java:60) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:415) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1425) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:66) ~[spring-orm-6.0.2.jar:6.0.2]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) ~[spring-orm-6.0.2.jar:6.0.2]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-6.0.2.jar:6.0.2]
... 110 common frames omitted Can you help plz, Thank u |
same issue with spring boot 3.0.0 |
This issue is closed, because the task it represented is done. |
I am also have this issue
|
As indicated by Jens, the exception is coming out of Hibernate. Please ensure you follow its 5 to 6 upgrade guide. |
No description provided.
The text was updated successfully, but these errors were encountered: