Collections having FK in superclass table

Description

Creating a OneToMany association to a joined subclass where the foreign key column already exists in the superclass of the joined subclass.

@OneToMany
@JoinColumn(name = "employee_id", table = "task_base")
private Set<Task> tasks;

When building the entity manager, the following exception occurs (due to the need for the 'table' property):

org.hibernate.cfg.NotYetImplementedException: Collections having FK in secondary table
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:2035)
at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:904)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:731)
at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:245)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:222)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:265)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:847)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:874)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:58)
...

Environment

None

Activity

Show:
Stephen Fikes
February 5, 2016, 11:10 PM

In the testcase, removing the explicit 5.0.7.Final reference from the pom.xml will revert to using the EAP bundled version of Hibernate.

Gail Badner
February 13, 2016, 5:01 AM

I've created a pull request with a test case that reproduces this issue: https://github.com/hibernate/hibernate-orm/pull/1265

Gail Badner
May 3, 2016, 5:52 AM

I've closed the pull request because it tests multiple associations that use the same foreign key, which is not supported.

Assignee

Gail Badner

Reporter

Stephen Fikes

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure