|
I seem to have a very similar issue, also with indirect sub-entities of a base entity, using Hibernate 3.2.6 with JPA-Extensions. The only difference is that the "Unknown column ... in 'field list'" error reported above happens when using an EntityManager for polymorphic loading of leaf class instances (like VerySpecialParent in the original example) using "em.find(SpecialParent.class, id)" or "em.getReference(SpecialParent.class, id)".
The problem seems to be that Hibernate tries to load the discriminator column from the given entity class's table (i.e. SpecialParent) instead of the table of the entity where the discriminator is defined (i.e. Parent).
To me this looks very serious, as it basically means entity inheritance hierarchies over more than one class hierarchy level are partially broken in Hibernate, at least using the JOINED inheritance strategy in conjunction with discriminators. After all, we're talking about some pretty fundamental functionality here. Luckily, in my case there is an easy work around by simply using the base entity for the polymorphic identity query:
Parent parent = entityManager.find(Parent.class, id); if (parent == null || !(parent instanceof SpecialParent)) return; SpecialParent specialParent = (SpecialParent) parent; ...
When/if this is fixed, can you also consider backporting the fix to the latest 4.2.x versions of Hibernate? The 4.3.x series suffers from unrelated show stopping issues, so I cannot use these newer versions ...
|