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

后端 未结 5 770
面向向阳花
面向向阳花 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:22

    JPA 2 (Hibernate 3.5) adds support for non-polymorphic queries, this is very similar to Hibernates .class property (as Bozho answered above) but it is not Hibernate specific. This is done using the TYPE operator. As in

    Select b from Book b where TYPE(b) = Book
    

    You can read more about here it in my blog

    Eyal

提交回复
热议问题