• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ORM Relationship question

New Here ,
Nov 23, 2015 Nov 23, 2015

Copy link to clipboard

Copied

Hi Guys

I'm still working on a CF9 environment and starting to develop a new system, that is going to be used for multiple clients and that is going to include lots of "addons". Some versions of this system won't have all add-ons and will have a sub set of them.

To try and make this as flexible as possible, I am trying to create a parent persistent entity, that creates my database table, has primary key, most details etc. Then for each addon I won't to include an extended class of the parent that includes some additional mapping to the addon specific persistent class. I then want to be able to call the parent entity but have it include these extended properties. Is this possible? I have tried using "mappedsuperclass" but as I have an even high level entity linking one-to-many to this parent entity, that starts to error.

I'm not even sure if this possible but any help would be great as my head is now fried looking at relational databases

Many thanks

Tom

Views

133

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 23, 2015 Nov 23, 2015

Copy link to clipboard

Copied

LATEST

To elaborate further:

I have a top level entity "tblSite_Pages" created here:


<cfcomponent persistent="true">
<cfproperty name="pageID" type="numeric" fieldtype="id" sqltype="int" generator="native" ormtype="int">

<!--- RELATIONS --->

<cfproperty name="DetailsObj" type="array" fieldtype="one-to-many" cfc="tblSite_Pages_Details" cascade="all" fkcolumn="PageID" orderby="Datecreated DESC" where="Deleted = 0">

</cfcomponent>


This then links through to the main details entity "tblSite_Pages_Details":


<cfcomponent persistent="true" table="tblSite_Pages_Details">

<cfproperty name="detailsID" type="numeric" fieldtype="id" sqltype="int" generator="native" ormtype="int"> 

<cfproperty name="pageTitle" type="string" sqltype="varchar(max)" ormtype="string" notnull="true">

<cfproperty name="pageContent" type="string" sqltype="varchar(max)"  ormtype="string" notnull="true">

<cfproperty name="deleted" type="numeric" sqltype="int" ormtype="int" notnull="true">

<!--- RELATIONS --->

<cfproperty name="PageID" notnull="true" fieldtype="many-to-one" cfc="tblSite_Pages">

</cfcomponent>

It is this persistent object that I want to extend somehow to be able add more relationships, to other persistent objects but done dynamically dependant on what addons are found elsewhere (set folders) in the system.

The end game of this, is I wont to call one object, tblSite_Pages and get all related entities with the one call. Writing this in SQL and building the database manually, is possible, but I would like to utilise ORM for this.

Is this possible?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation