Last active
August 29, 2015 14:02
-
-
Save thecfguy/ba7bcc1a11d49f973114 to your computer and use it in GitHub Desktop.
ORM One-To-Many
This file contains 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 output="false" singleton{ | |
// Default Action | |
property name="masterService" inject="entityService:tmaster" scope="variables"; | |
property name="detailService" inject="entityService:tdetail" scope="variables"; | |
function index(event,rc,prc){ | |
var masterbean = masterService.new({col1:"master"}); | |
var detailbean = detailService.new({col2:"detail"}); | |
/* save with master bean | |
database operations: | |
2 insert query and 1 update query | |
*/ | |
masterbean.addDetail(detailbean); | |
masterService.save(masterbean); | |
event.setView("test"); | |
} | |
} |
This file contains 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 displayname="tdetail" output="false" persistent="true" { | |
property name="id" fieldtype="id" generator="identity"; | |
property name="col2" type="string"; | |
property name="master" fieldtype="many-to-one" cfc="tmaster" fkcolumn="masterid" cascade="all"; | |
} |
This file contains 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 displayname="tmaster" output="false" persistent="true" { | |
property name="id" fieldtype="id" generator="identity"; | |
property name="col1" type="string"; | |
property name="details" type="array" fkcolumn="masterid" fieldtype="one-to-many" cfc="tdetail" cascade="all" singularname="detail"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment