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

Test: having map key as an object and map annotated with a @MapKeyClass fails to boot #8096

Closed

Conversation

marko-bekhta
Copy link
Member

Having some map with an object key and @MapKeyClass, e.g.:

@OneToMany(mappedBy = "school")
@MapKeyClass(Date.class)
@MapKeyColumn(name = "THE_DATE")
@MapKeyTemporal(TemporalType.DATE)
private Map<Object, Person> studentsByObjectThatIsDate;

Leads to an error:

org.hibernate.AnnotationException: Property 'org.hibernate.orm.test.jpa.MapKeyTest$School.studentsByObjectThatIsDate' has an unbound type and no explicit target entity (resolve this generics usage issue or set an explicit target attribute with '@OneToMany(target=)' or use an explicit '@Type')
	at org.hibernate.boot.model.internal.PropertyContainer.verifyAndInitializePersistentAttributes(PropertyContainer.java:324)
	at org.hibernate.boot.model.internal.PropertyContainer.resolveAttributeMembers(PropertyContainer.java:134)
	at org.hibernate.boot.model.internal.PropertyContainer.<init>(PropertyContainer.java:95)
	at org.hibernate.boot.model.internal.InheritanceState.getElementsToProcess(InheritanceState.java:225)
	at org.hibernate.boot.model.internal.InheritanceState.postProcess(InheritanceState.java:164)
	at org.hibernate.boot.model.internal.EntityBinder.handleIdentifier(EntityBinder.java:406)
	at org.hibernate.boot.model.internal.EntityBinder.bindEntityClass(EntityBinder.java:248)
	at org.hibernate.boot.model.internal.AnnotationBinder.bindClass(AnnotationBinder.java:255)
	at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:209)
	at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:334)
	at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.coordinateProcessors(MetadataBuildingProcess.java:377)
	at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:227)
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1431)
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1502)
	at org.hibernate.testing.orm.junit.EntityManagerFactoryExtension$EntityManagerFactoryScopeImpl.createEntityManagerFactory(EntityManagerFactoryExtension.java:328)
	at org.hibernate.testing.orm.junit.AbstractEntityManagerFactoryScope.getEntityManagerFactory(AbstractEntityManagerFactoryScope.java:38)
	at org.hibernate.testing.orm.junit.AbstractEntityManagerFactoryScope.inTransaction(AbstractEntityManagerFactoryScope.java:124)
	at org.hibernate.orm.test.jpa.MapKeyTest.testMapKeyTemporal(MapKeyTest.java:69)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)

Noticed this while testing Search against 7.0. This kind of mapping worked in the previous versions. Is this a new rule, or should ORM try to figure out the type since there's a @MapKeyClass annotation?

@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: [6699950]

› This message was automatically generated.

@dreab8
Copy link
Contributor

dreab8 commented Apr 3, 2024

@marko-bekhta this should fix the issue

marko-bekhta added a commit to hibernate/hibernate-search that referenced this pull request Apr 3, 2024
marko-bekhta added a commit to hibernate/hibernate-search that referenced this pull request Apr 22, 2024
marko-bekhta added a commit to hibernate/hibernate-search that referenced this pull request Apr 23, 2024
marko-bekhta added a commit to hibernate/hibernate-search that referenced this pull request Apr 28, 2024
marko-bekhta added a commit to hibernate/hibernate-search that referenced this pull request Apr 29, 2024
marko-bekhta added a commit to hibernate/hibernate-search that referenced this pull request May 6, 2024
marko-bekhta added a commit to hibernate/hibernate-search that referenced this pull request May 16, 2024
marko-bekhta added a commit to hibernate/hibernate-search that referenced this pull request May 27, 2024
marko-bekhta added a commit to hibernate/hibernate-search that referenced this pull request Jun 3, 2024
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.

2 participants