How to perform a non-polymorphic HQL query in Hibernate?

后端 未结 5 775
面向向阳花
面向向阳花 2020-11-30 05:43

I\'m using Hibernate 3.1.1, and in particular, I\'m using HQL queries.

According to the documentation, Hibernate\'s queries are polymorphic:

A

5条回答
  •  长情又很酷
    2020-11-30 06:18

    Look at BaseQueryReturnFieldsCalculatorGC; it dynamically adds a condition to the 'where' which selects only where class=XXX; you can duplicate this logic to the HQLQueryTemplate and have the user define 'isNonPolymorphic'.

    Note that it will only work with table-per-hierarchy, cos only then does the implicit class column exist and is selectable.

提交回复
热议问题