We have the following class hierarchy:
entity A extends from B (mapped superclass).
AccessType is PROPERTY.
class A defines a method getTest() which is overriden in class B.
This causes the following exception:
Caused by: org.hibernate.MappingException: Duplicate property mapping of testA found in sample.entities.B
the attached zip contain a testcase.
For the extends-Entity case.. ah right... because the Subclass sees the column with the same name from the RootClass. Fundamentally its the same issue. In both cases we process the attribute from both the super and sub. The difference is just that we don't model MappedSuperclass "inline" with the PersistentClass hierarchy so that Property literally gets duplicated into each sub (hence the dup Property exception).
We use the artifacts that came bundled with JBoss 4.2.2. Then manifest of hibernate-entitymanager says:
The one from hibernate3:
Like I said, I was not able to get this to work with annotations using any versions of Hibernate. And I went back pretty far. I went back as far as org.hibernate:hibernate-entitymanager:3.2.0.ga which is even further back than you use. And in no version I tried did this ever work.
Anyway, I fixed it yesterday. GIve it is a try. The solution is not ideal, but I think it is the best we can do until I get the time to completely revamp annotation binding.
Steve, I just realized the test case I ran within JBoss was slightly different than the one posted here. I did not specify an AccessType on my entity, and appearently it defaulted to AccessType.FIELD. Also, my error message was different:
java.sql.SQLException: Invalid column index
I can replicate that error message with the attached test case when annotating class B with @Access(AccessType.FIELD).
This might explain, why you were not able to verify that the code worked with older versions of hibernate, it might only have worked with AccessType.FIELD. Luckily, your fix solves both cases, with Hibernate 5.0.9 the test case succeeds with both AccessTypes.
Now my only problem is that I cannot get Hibernate 5 to work within JBoss 7 (class mismatches during startup prevent UserTypes from being applied...).
Steve's patch applies almost cleanly to Hibernate 4.2.23, so I was able to integrate it into JBoss 7 by backporting it and replacing the bundled version of Hibernate in JBoss with the patched version of Hibernate 4.2.23.