1 Reply Latest reply on Nov 23, 2015 5:26 AM by tomarse

    ORM Relationship question


      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


        • 1. Re: ORM Relationship question
          tomarse Level 1

          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">


          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">



          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?