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

Missing hibernate's TenantIdBinder #478

Closed
itineric opened this issue Apr 11, 2024 · 3 comments
Closed

Missing hibernate's TenantIdBinder #478

itineric opened this issue Apr 11, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@itineric
Copy link

Describe the bug
When using hibernate @org.hibernate.annotations.TenantId annotation on JPA entities, native execution does not work anymore.

To Reproduce
Add some @org.hibernate.annotations.TenantId on a JPA entity property

Expected behavior
Keep org.hibernate.binder.internal.TenantIdBinder class

Logs

Caused by: org.hibernate.AnnotationException: error processing @AttributeBinderType annotation '@org.hibernate.annotations.TenantId()'
	at org.hibernate.boot.model.internal.PropertyBinder.callAttributeBinders(PropertyBinder.java:285) ~[na:na]
	at org.hibernate.boot.model.internal.PropertyBinder.lambda$bind$964ff3a4$1(PropertyBinder.java:339) ~[na:na]
	at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1815) ~[data-manager-backend:6.4.4.Final]
	at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1774) ~[data-manager-backend:6.4.4.Final]
	at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:332) ~[na:na]
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1432) ~[na:na]
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1503) ~[na:na]
	at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:75) ~[na:na]
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:390) ~[data-manager-backend:6.1.5]
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[data-manager-backend:6.1.5]
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[data-manager-backend:6.1.5]
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:366) ~[data-manager-backend:6.1.5]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1833) ~[data-manager-backend:6.1.4]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782) ~[data-manager-backend:6.1.4]
	... 14 common frames omitted
Caused by: java.lang.InstantiationException: org.hibernate.binder.internal.TenantIdBinder
	at [email protected]/java.lang.Class.newInstance(DynamicHub.java:639) ~[data-manager-backend:na]
	at org.hibernate.boot.model.internal.PropertyBinder.callAttributeBinders(PropertyBinder.java:281) ~[na:na]
	... 27 common frames omitted
Caused by: java.lang.NoSuchMethodException: org.hibernate.binder.internal.TenantIdBinder.<init>()
	at [email protected]/java.lang.Class.checkMethod(DynamicHub.java:1038) ~[data-manager-backend:na]
	at [email protected]/java.lang.Class.getConstructor0(DynamicHub.java:1204) ~[data-manager-backend:na]
	at [email protected]/java.lang.Class.newInstance(DynamicHub.java:626) ~[data-manager-backend:na]
	... 28 common frames omitted

System Info (please complete the following information):

  • OS: debian
  • GraalVM CE 17.0.8+7.1 (build 17.0.8+7-jvmci-23.0-b15)
  • Java Version 17
  • spring native compilation
@itineric itineric added the bug Something isn't working label Apr 11, 2024
@itineric
Copy link
Author

org.hibernate.generator.internal.TenantIdGeneration seems needed too

@fniephaus
Copy link
Member

Could you take a look at this please, @mhalbritter?

@mhalbritter mhalbritter assigned sdeleuze and unassigned mhalbritter Apr 30, 2024
@sdeleuze
Copy link
Collaborator

sdeleuze commented Jun 6, 2024

This can be fixed by dynamic attribute handling so I fixed that on Spring side with spring-projects/spring-framework#32967 + spring-projects/spring-framework#32842.

@sdeleuze sdeleuze closed this as not planned Won't fix, can't repro, duplicate, stale Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants