2

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

feder
  • 1,849
  • 2
  • 25
  • 43
  • 1
    Do you have only the two order types: Mini and Sub? In other words, does it work with any other implementations of GenericOrderType? – carbontax Jul 09 '14 at 12:03
  • I gave in finding a solution and simply used `...from MiniOrderType` instead of `...AND type(o) = 'MiniOrderType'`. That is okay, too. At least for JPA1.0 – feder Jul 09 '14 at 13:23

0 Answers0