hi there, i don't know hot to define this, so i'll explain..
i have a class called AbstractCaseAttribute, which has several implementations. essentially, it's a field which a common dominator of integer which states the meaning of the field (property called TypeId, which could be for example 7 for name, and 9 for age).
the sub-implementation represent the type the field might com into play,
for example i have StringCaseAttriutbte, which only adds a one proprety called value and it's type String, i also have NumericCaseAttribute, which has 2 properies one Value of type Double, and one Unit of type int (to represent measured units id)
i also have DateCaseAttribute, which contains 3 fields of type int (day,month,year).
now this gets complicated, i also have a subtype called PERIOD (representing a period of time) , which actually is composed of 3 sub classes i specfied earlierL NumericCaseAttribute (interval Period), DateCaseAttribute (start period) and another DateCaseAttribute(end date Period).
so in the same hbm i'm trying to define a a subclass which has components of other subclasses defined in the same hbm.
when i try this, the table doesn't get created (which one of most annyoing things, in hbm2ddl btw, everytime i have a problem with an hbm, i never get an error, it's simply not created).
is this possible, is there another way?
Hibernate version: 2.1.7c
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="com.pnx.underwrite.bo.underwritemodel.questionareinput" default-cascade="none" default-access="property" auto-import="true">
<class name="AbstractQuestionareAttributeBo" table="underwrite_CaseAttributes" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false" batch-size="1" select-before-update="false" optimistic-lock="version">
<id name="id" type="long" access="property" unsaved-value="-1"> <generator class="native"/></id>
<discriminator column="AttributeDataType"/>
<property name="typeId" not-null="false" unique="false" update="true" insert="true"/>
<property name="name" not-null="false" unique="false" update="true" insert="true"/>
<property update="false" access="property" type="timestamp" column="CREATED" name="created"/>
<property update="true" access="property" type="timestamp" column="MODIFIED" name="modified"/>
<property update="true" not-null="true" access="property" type="boolean" column="DELETED" name="deleted"/>
<many-to-one name="caseObjectBo" class="QuestionareCaseObjectBo" column="CaseObjectPrimaryKey" not-null="false" unique="false" outer-join="auto" update="true" insert="true"/>
<many-to-one name="compassSource" class="CompassSourceBO" column="CompassSourcePrimaryKey" not-null="false" unique="false" outer-join="auto" update="true" insert="true"/>
<subclass name="DbEnumQuestionareAttributeBo" discriminator-value="DBEnum" extends="AbstractQuestionareAttributeBo" dynamic-update="false" dynamic-insert="false" select-before-update="false">
<property name="code" column ="dbEnumValue"/>
<property name="description"/>
</subclass>
<subclass name="DbCodeQuestionairAttributeBo" discriminator-value="DBKey" extends="AbstractQuestionareAttributeBo" dynamic-update="false" dynamic-insert="false" select-before-update="false">
<property name="code" column ="dbCodeValue" />
<property name="description"/>
<property name="locale"/>
</subclass>
<subclass name="NumericQuestionareAttributeBo" discriminator-value="NUM" extends="AbstractQuestionareAttributeBo" dynamic-update="false" dynamic-insert="false" select-before-update="false">
<property name="value" column ="numberValue" type="double"/>
<property name="unit"/>
</subclass>
<subclass name="StringQuestionareAttributeBo" discriminator-value="STR" extends="AbstractQuestionareAttributeBo" dynamic-update="false" dynamic-insert="false" select-before-update="false">
<property name="value" column ="stringValue" />
</subclass>
<subclass name="DateValueQuestionaireBo" discriminator-value="DATE" extends="AbstractQuestionareAttributeBo" dynamic-update="false" dynamic-insert="false" select-before-update="false">
<property name="day"/>
<property name="month"/>
<property name="year"/>
</subclass>
<subclass name="PeriodQuestionareAttributeBo" discriminator-value="PERIOD" extends="AbstractQuestionareAttributeBo" dynamic-update="false" dynamic-insert="false" select-before-update="false">
<!-- <many-to-one name="from" class="DateValueQuestionaireBo" column="from" cascade="all" not-null="false" unique="false" outer-join="auto" update="true" insert="true"/>
<many-to-one name="to" class="DateValueQuestionaireBo" column="to" cascade="all" not-null="false" unique="false" outer-join="auto" update="true" insert="true"/>
<many-to-one name="period" class="NumericQuestionareAttributeBo" column="period" cascade="all" not-null="false" unique="false" outer-join="auto" update="true" insert="true"/>-->
<component name="from" class="DateValueQuestionaireBo"/>
<component name="to" class="DateValueQuestionaireBo"/>
<component name="period" class="NumericQuestionareAttributeBo"/>
</subclass>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Name and version of the database you are using: oracle 9
The generated SQL (show_sql=true):
|