This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have two java classes, CurrentData and HistoricData, where HistoricData extends CurrentData.
There is no relationship implied or intended between the hibernate mappings, the tables are almost identical, but where one has a currentFkId column the other has a historicFkId column.
While this might be a weird situation, I don't believe it should break any of Hibernate's assumptions. However, we have a Named Query with the HQL , and for some as yet unknown reason, when Hibernate tries to render that query, it replaces the parent class with it's sub-class, rendering the above HQL as and throws an Exception pasted below.
Why has Hibernate decided to take my perfectly legitimate Class name, and replace it with an arbitrary sub-class? It runs counter to all the Java conventions. On the assumption that this is an issue with Hibernate, I've tried rearranging the order of the Mapping files in my hibernate.cfg to see if the order of class registration matters, and I've added a hibernate.query.substitution rule that explicitly mapped CurrentData=org.mycompany.CurrentData. Neither change seemed to have any effect.
Any advice you're able to offer, either in explaining what's going on, or in suggesting ways to get my desired behavior would be most welcome.