Hi, I'm new to Hibernate and I'm trying to make a persistent subclass to work.
Here's my TradeOrder.hbm.xml mapping:
?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<!-- com.biz.orders.TradeOrder root -->
<class name="com.biz.orders.TradeOrder" table="TradeOrder" discriminator-value="T" mutable="true" polymorphism="implicit" dynamic-update="true" dynamic-insert="true" batch-size="1" select-before-update="false" optimistic-lock="version">
<id name="id" type="string">
<column name="id" length="16"/>
<generator class="native"/>
</id>
<discriminator column="subclass" type="character"/>
<property name="hora" column="hora" type="timestamp"/>
<property name="status" column="status" type="serializable"/>
<component name="user" class="com.biz.common.User">
<property name="password" column="password" type="string"/>
<bag name="accounts" table="accounts" lazy="true">
<key column="uid"/>
<element column="elm" type ="string"/>
</bag>
</component>
<property name="orderType" column="orderType" type="string"/>
<property name="stamp" column="stamp" type="timestamp"/>
<component name="account" class="com.biz.common.Account">
<property name="ID" column="IDAccount" type="string"/>
<bag name="permissions" table="permissions" lazy="true">
<key column="uid_1"/>
<element column="elm_1" type ="string"/>
</bag>
<property name="titular" column="titular" type="string"/>
</component>
<bag name="fills" table="fills" lazy="true">
<key column="uid_2"/>
<element column="elm_2" type ="string"/>
</bag>
<!-- com.biz.orders.SimpleOrder -->
<subclass name="com.biz.orders.SimpleOrder" discriminator-value="S" dynamic-update="true" dynamic-insert="true">
<property name="accion" column="accion" type="serializable"/>
<property name="size" column="size" type="float"/>
<property name="market" column="market" type="serializable"/>
<property name="PCode" column="PCode" type="string"/>
<!-- com.biz.orders.LimitOrder -->
<subclass name="com.biz.orders.LimitOrder" discriminator-value="L" dynamic-update="true" dynamic-insert="true">
<component name="price" class="com.biz.common.Price">
<property name="money" column="money" type="string"/>
<property name="magnitude" column="magnitude" type="float"/>
</component>
</subclass>
</subclass>
</class>
</hibernate-mapping>
I'm trying to insert a new record in the Trade Order table, inserting a Limit Order , and an Exception is thrown:
No persister for: com.biz.orders.LimitOrder
net.sf.hibernate.MappingException: No persister for: com.biz.orders.LimitOrder
at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:420)
What I'm doing wrong?
|