NoSuchElementException in AnnotationBinder.makeInheritanceJoinColumns() when Joined
subclass mixed with @MapsId foreign-key id
------------------------------------------------------------------------------------------------------------------------------
Key: HHH-7135
URL:
https://hibernate.onjira.com/browse/HHH-7135
Project: Hibernate ORM
Issue Type: Bug
Components: core
Affects Versions: 4.1.0
Environment: Hibernate 4.1.0.Release, any database
Reporter: Didier Villevalois
Attachments: jpa-test-joined.zip
When you have a joined class hierarchy and the root class is has a foreign-key id,
makeInheritanceJoinColumns fails.
@Entity(name = "org.clinigrid.jpa.test.joined.AThing")
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class AThing {
public AThing() {
}
public AThing(ThingHolder holder) {
this.holder = holder;
}
@Id
// @GeneratedValue(generator = "foreign")
// @GenericGenerator(name = "foreign", strategy = "foreign",
parameters = { @Parameter(name = "property", value = "holder") })
private Integer id;
@MapsId
@OneToOne(mappedBy = "thing")
private ThingHolder holder;
public Integer getId() {
return id;
}
public ThingHolder getHolder() {
return holder;
}
}
java.util.NoSuchElementException
at java.util.ArrayList$Itr.next(ArrayList.java:757)
at org.hibernate.cfg.Ejb3JoinColumn.buildJoinColumn(Ejb3JoinColumn.java:323)
at
org.hibernate.cfg.AnnotationBinder.makeInheritanceJoinColumns(AnnotationBinder.java:1125)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:564)
at
org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3431)
at
org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3385)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1337)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1727)
at
org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:88)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)
at
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at
org.clinigrid.jpa.test.joined.JoinedSubclassAndForeignIdTest.test(JoinedSubclassAndForeignIdTest.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Commenting the @MapsId and un-commenting the @GeneratedValue and @GenericGenerator fixes
the problem.
I was not able to find the root of the problem in hibernate's code.
Attached is a test maven project.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira