Hi guys
I am migrating my project from xml mapping to annotations, I am stuck on Table per class hierarchy inheritance.
In xml mapping i was doing this
Code:
<hibernate-mapping package="com.company.common.web.preferences" default-access="field">
<class name="Element" table="ELEMENT" discriminator-value="0" >
<composite-id name="id" class="ElementId">
<key-property name="elementId" column="ELEMENT_ID" type="long"/>
<key-property name="userId" column="USR_ID" type="string"/>
</composite-id>
<discriminator column="TYPE" type="integer" insert="true" />
<subclass name="com.company.center.web.preferences.A
discriminator-value="4">
...
</subclass>
</class>
</hibernate-mapping>
with annotations i am doing this
Code:
@Entity
@Table(name = "ELEMENT")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@org.hibernate.annotations.ForceDiscriminator
@DiscriminatorColumn(name = "TYPE", discriminatorType = DiscriminatorType.INTEGER)
public abstract class Element implements Serializable
@Id
private ElementId id;
Code:
@Entity
@DiscriminatorValue("4")
public class A extends Element
I am getting the following exception
Code:
Caused by: org.hibernate.MappingException: Unknown entity: com.company.common.web.preferences.Element
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:597)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:68)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:879)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:816)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:809)
at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:531)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
... 27 more
please help !