Hi all,
I am mixing table per class hierarchy and table per subclass strategies.
And I have different behaviours when trying to do a query.
Here is the inheritance tree:
Element <- Product <- CommercialProduct
I want to do a query on CommercialProduct.
When I'm using the Criteria API, with the following query:
Code:
getSession().createCriteria(CommercialProduct.class)
I got a WrongClassException saying that the object was alreay loaded as a Product.
When I am using an HQL query, it works fine:
Code:
getSession().createQuery(" from CommercialProduct ")
For the moment, it's only in a unit test. So I am not still dealing with objects already in session or other cases.
I tried to use discriminator force="true" with no changes.
By the way, when I look at SQL queries, I don't see the discriminated value in the where clause.
Can some one explain me why criteria uses the parent type to query?
Other question, the discriminated column should be used in the generated sql query, shouldn't it?
I am using Hibernate 3.3.2 with xml mapping (no annotations).
Thanks for your help.