Using JPA with Hibernate 3.3 as persistence provider.
Code:
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING)
public class Lov extends BaseEntity {
private String name;
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
}
Code:
@Entity
@DiscriminatorValue("strategy")
public class StrategyType extends Lov {
}
BaseEntity is an entity with id, version, create/update dates
My query is "Select s from Strategy s"
I get an error
Code:
Caused by: org.hibernate.hql.ast.QuerySyntaxException: Strategy is not mapped [from Strategy]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:158)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87)
Any ideas how to query inherited objects in a "single table per class hierarchy" mode?