Mixing multiple inheritance strategies

63 views
Skip to first unread message

Daniel

unread,
Oct 1, 2010, 1:26:54 PM10/1/10
to cf-orm-dev
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

Marc Esher

unread,
Oct 1, 2010, 2:06:42 PM10/1/10
to cf-or...@googlegroups.com
Daniel,

I believe you need the following:

1) Tour.cfc needs a discriminatorColumn="tourTypeID" in its component definition

presumably daytour has a tourTypeID of 1 and cruise has a tourTypeID
of 2, or something like that

2) DayTour.cfc needs a discriminatorValue="1" in its component definition

3) Cruise.cfc needs a discriminatorValue="2" in its component definition.

Replace 1 and 2 with the appropriate IDs for daytour and cruise, respectively.

I do not think you need the joincolumn if you're doing a table per
hierarchy mapping.

Best,

Marc

> --
> You received this message because you are subscribed to the Google Groups "cf-orm-dev" group.
> To post to this group, send email to cf-or...@googlegroups.com.
> To unsubscribe from this group, send email to cf-orm-dev+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cf-orm-dev?hl=en.
>
>

Daniel

unread,
Oct 4, 2010, 6:45:08 AM10/4/10
to cf-orm-dev
Marc,

I try to make it more clear... The single table inheritance worked
( same a you described). But it fails when I mixed it with table per
class hierachie of the parent entity.

tour
-- cruise //single table hierarchy to tour
-- daytou r//single table hierarchy to tour

work as expected with discriminatorValues for cruise and daytour. BUT
as soon as I use the inheritance of the parent class Product->Tour. I
get the error:
"No discriminator found for daytour/cruise. Discriminator is needed
when 'single-table-per-hierarchy' is used and a class has subclasses"

product //base entity
---tour //table per class hierarchy with products
---- cruise //single table hierarchy to tour


the code:

component display="product" persistent="true"{
property name="item_id" type="uuid" ormtype="string" fieldtype="id"
generator="uuid" hint="key of the product";
}

component display="tour" extends="product" persistent="true"
joincolumn="item_id" discriminatorcolumn="tourtype"{
}

component display="cruise" extends="tour" table="tour"
discriminatorValue="cruise" persistent="true"{
property name="vessel" type="string";
}

I'm not sure if this i bug (!!!) because according to the hibernate
documentation mixing multiple inheritance strategies should be
possible.

Daniel
> >http://docs.jboss.org/hibernate/core/3.3/reference/en/html/inheritanc...

Marc Esher

unread,
Oct 4, 2010, 6:47:35 AM10/4/10
to cf-or...@googlegroups.com
Daniel,
I myself and seeing something with respect to inheritance that sure
as heck feels like a bug to me. Perhaps it's best to post this case as
a bug in the Adobe bug tracker and see what happens.

Marc

Daniel

unread,
Oct 4, 2010, 7:48:03 AM10/4/10
to cf-orm-dev
I think mixing inheritance strategies should be possible and I'm quite
sure it's bug!

But since I'm not an hibernate expert I want to check if I perhaps
overlooked something.

anybody else?

Daniel

On 4 Okt., 12:47, Marc Esher <marc.es...@gmail.com> wrote:
> Daniel,

Brett

unread,
Oct 4, 2010, 9:32:16 AM10/4/10
to cf-orm-dev
I got further than the error, but can't get the correct schema to be
generated.

I added the discriminatorcolumn attribute to product.cfc

discriminatorcolumn="tourtype"

Then a default discriminatorvalue to tour.cfc

discriminatorValue="tour"

If this isn't added you'll get a "No default value for tourtype
defined" error. You can also remove the discriminatorcolumn attribute
from tour.cfc

Then I added a discriminatorValue to cruise.cfc

discriminatorValue="cruise"

###

The entities work as expected but the discriminator and all the cruise
and daytour properties are persisted in the product table rather than
the tour table.

You should defiantly open a bug for this one and post the # here so we
can vote.

.brett

Daniel

unread,
Oct 4, 2010, 11:03:09 AM10/4/10
to cf-orm-dev
thanks Brett for validating.

I opend a bug report with #384520

for anybody to vote for:
http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html#bugId=84520

Daniel

Brett

unread,
Oct 4, 2010, 6:22:07 PM10/4/10
to cf-orm-dev
No problem, voted. This seems like pretty serious issue I'll run into
pretty soon.

I tested on the latest Railo and opened the issue there too:

https://jira.jboss.org/browse/RAILO-989


On Oct 4, 11:03 am, Daniel <daniel.sch...@gmail.com> wrote:
> thanks Brett for validating.
>
> I opend a bug report with #384520
>
> for anybody to vote for:http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html#...

Chris Blackwell

unread,
Oct 22, 2010, 2:11:33 PM10/22/10
to cf-or...@googlegroups.com
I've just hit this exact issue, i've added my vote on the tracker.
I'd be interested to know how people have worked around this issue

Cheers, Chris

Wesley Hampton

unread,
Aug 28, 2015, 11:10:59 AM8/28/15
to cf-orm-dev
I apologize for dredging up this five year old thread, but I'm running into a similar problem and wondered if anyone ever resolved this with CF component attributes or annotations?

Or, must .hbmxml files be used...and are those confirmed to work for anyone? I haven't used .hbmxml files and didn't want to waste time on that road if it's proven futile.

Essentially I am trying to implement inheritance where some of the subtypes have their own tables while others do not: http://docs.jboss.org/hibernate/orm/3.5/reference/en/html/inheritance.html#inheritance-mixing-tableperclass-tablepersubclass

Thanks!
Wes
Reply all
Reply to author
Forward
0 new messages