In fairly complex application I tried to mixing table per subclass
and table per class hierarchy inheritance
product
- hotel
- tour
- - daytour
- - cruise
hotel and tour have table per class hierarchy since the share only
basic data properties. That's done with table per subclass and a
joincolumn.
than daytour, cruise are subclasses from tour and have only some
different properties than tour thus I tried to use table per hierarchy
with a table "tour".
When I reload ORM I get an error "No discriminator found for cruise.
Discriminator is needed when 'single-table-per-hierarchy' is used and
a class has subclasses". But I have clearly a discriminatorvalue in
the entity cruise.
I should be possible editing the hbmxml file:
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/inheritance.html#inheritance-mixing-tableperclass-tablepersubclass
But I'm wondering if it is possible using some clever CF annotation?
The code:
component hint="I'm the base product component" output="false"
persistent="true" display="product"
{
property name="item_id" type="uuid" ormtype="string" fieldtype="id"
generator="uuid" hint="key of the product";
property name="thumbnail_small" type="string";
property name="thumbnail_big" type="string";
property name="teaser" ormtype="text" type="string" hint="the
teasertext the in master list";
property name="description" type="string" ormtype="text" hint="free
text description of the product";
property name="highlights" ormtype="text" hint="highlighs tour as
free text" type="string";
}
component hint="i'm the classs for tour" extends="product"
output="false" persistent="true" joincolumn="item_id"
discriminatorcolumn="tourtype"
{
/* properties */
property name="duration" type="string" ormtype="string"
hint="duration as text";
property name="meetinglocation" ormtype="text" hint="meeting location
as free text" type="string";
property name="meetingtime" ormtype="string" hint="meetingtime"
type="string";
property name="departuretime" type="string" ormtype="string"
displayname="time of the departure" hint="time of the departure";
property name="returntime" type="string" ormtype="string" hint="when
we come back from the tour";
property name="maxpeople" ormtype="int" type="numeric" hint="maximun
people for a tour";
property name="minpeople" ormtype="int" type="numeric" hint="minimun
people for a tour";
}
component output="false" persistent="true" extends="tour" table="tour"
discriminatorValue="cruise"
{
property name="vessel" type="string";
}
thx
Daniel
--
www.danielschmid.name