Created
December 17, 2013 09:33
-
-
Save thecfguy/8002350 to your computer and use it in GitHub Desktop.
One-to-One relationship with primary key and unique key combination. This example has relationship triangle. :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <cfscript> | |
| ormreload(); | |
| //Save | |
| objt6 = tbl6Service.new({"col":"tbl6"}); | |
| objt7 = tbl7Service.new({"col":"tbl7"}); | |
| objt8 = tbl8Service.new({"col":"tbl8"}); | |
| objt6.addTbl8(objt8); | |
| objt6.setTbl7(objt7); | |
| objt7.settbl6(objt6); | |
| objt7.settbl8(objt8); | |
| objt8.settbl6(objt6); | |
| entitysave(objt6); | |
| </cfscript> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| component name="tbl6" persistent='true' accessors="true"{ | |
| property name="id" fieldtype="id" generator="native"; | |
| property name="col"; | |
| property name="tbl7" fieldtype="one-to-one" cfc="tbl7" cascade="all"; | |
| property name="tbl8s" cascade="all-delete-orphan" fieldtype="one-to-many" singularname="tbl8" | |
| cfc="tbl8" type="array" inverse="true"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| component name="tbl7" persistent='true' accessors="true"{ | |
| property name="tbl7id" fieldtype="id" generator="foreign" params="{property='tbl6'}"; | |
| property name="tbl6" fieldtype="one-to-one" cfc="tbl6" constrained="true"; | |
| property name="col"; | |
| property name="tbl8" fkcolumn="tbl8id" fieldtype="one-to-one" cfc="tbl8" cascade="all"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| component name="tbl8" persistent='true' accessors="true"{ | |
| property name="id" fieldtype="id" generator="native"; | |
| property name="col"; | |
| property name="tbl7" fieldtype="one-to-one" cfc="tbl7" mappedBy="tbl8"; | |
| property name="tbl6" fieldtype="many-to-one" cfc="tbl6" fkcolumn="tbl6id"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment