HQL-query with discriminator column cannot query by type of subclass

1.4k Views Asked by At

I'm using JPA1.0 and Hibernate 3.3. (There is currently no option to upgrade).

I want to query a generic table GenericOrderType with @Inheritance(strategy = InheritanceType.SINGLE_TABLE) strategy and @Discriminatorcolumn(name="ORDER_TYPE").

Running the following query WITHOUT AND type(o) = 'SubOrderType' works.

select OBJECT(o) from GenericOrderType o where o.id = :orderid AND type(o) = 'MiniOrderType'

If I append AND type(o) = 'MiniOrderType' I get a persistence exception.

javax.persistence.PersistenceException: org.hibernate.HibernateException: Unable to resolve entity name from Class [java.lang.String] expected instance/subclass of [com.doe.GenericOrderType]

I did not find the correct syntax to query by type (subclass) with Hibernate 3.3 and JPA 1. http://docs.jboss.org/hibernate/core/3.3/reference/en-US/html/

Any hints appreciated.

Thank you

0

There are 0 best solutions below