Attached SpringBoot JPA project with minimal configuration reproduces inheritance related JPQL queries bugs in Hibernate ORM. The idea is simple: create a query able to return mapped entities of certain type or all of them (when no type is supplied). First query *findByClass* from DAO works with SINGLE_TABLE inheritance, though is not JPA compliant. Second, *findByTypeClass*, never works resulting in bootstrap failure with misleading exception, though is recommended by documentation. Third, *findByTypeString*, works partially only with certain inheritance strategy. Fourth, *findByClassIn*, always works since it's pretty much documentation example, though it does not fulfill original goal and put there just for a reference. Fifth, *findByClassInNullSafe*, is an extension of previous and works partially does not fulfill the goal . Worth It's worth mentioning an interesting exception of findByClass with other but SINGLE_TABLE inheritance type used. Please, check attached project test cases for details. Seems, such inconsistency in Hibernate inheritance implementation exists since 3d version of ORM (according to *unresolved *similar Jira issues). Could someone elaborate on such behavior, suggest recommended/working example of query reaching same goal (common production task case ) or fix it in next Hibernate release . ? |
|