<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ColdFused? &#187; centaur</title>
	<atom:link href="http://www.rupeshk.org/blog/index.php/tag/centaur/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rupeshk.org/blog</link>
	<description>My Views on ColdFusion, Java and related technologies</description>
	<lastBuildDate>Mon, 21 Jun 2010 12:40:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ColdFusion ORM : Terry Ryan answers some FAQ</title>
		<link>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-terry-ryan-answers-some-faq/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-terry-ryan-answers-some-faq/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 08:46:11 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[ORM]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[centaur]]></category>
		<category><![CDATA[orm]]></category>

		<guid isPermaLink="false">http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-terry-ryan-answers-some-faq/</guid>
		<description><![CDATA[When you hear about ORM in ColdFusion for the first time, there will be several questions coming to your head. Terrance Ryan answers some of those frequently asked questions in this great post. 
]]></description>
			<content:encoded><![CDATA[<p>When you hear about ORM in ColdFusion for the first time, there will be several questions coming to your head. Terrance Ryan answers some of those frequently asked questions in <a href="http://www.terrenceryan.com/blog/index.cfm/2009/7/13/Questions-about-ORM-in-ColdFusion-9">this great post</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-terry-ryan-answers-some-faq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion 9 : Implicit/Generated CFC Methods</title>
		<link>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-9-implicitgenerated-cfc-methods/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-9-implicitgenerated-cfc-methods/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 07:28:08 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[ORM]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[centaur]]></category>
		<category><![CDATA[orm]]></category>

		<guid isPermaLink="false">http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-9-implicitgenerated-cfc-methods/</guid>
		<description><![CDATA[How many times did you write the accessor methods (better known as getters and setters) for the fields of your CFC? And how many times did you feel that it was really a mundane job and wished there was a better way to do this? With ColdFusion 9, we have done just that! You no [...]]]></description>
			<content:encoded><![CDATA[<p>How many times did you write the accessor methods (better known as getters and setters) for the fields of your CFC? And how many times did you feel that it was really a mundane job and wished there was a better way to do this? With ColdFusion 9, we have done just that! You no longer need to write those accessors. ColdFusion will automatically generate the accessor methods for you in the object. All you need to do is to define the properties using cfproperty and set the attribute &#8216;accessors&#8217; to true on the component.</p>
<p>Consider this CFC Person.cfc</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @accessors true
 */</span>
<span style="color: #003399;">Component</span> Person<span style="color: #009900;">&#123;</span>
    property firstname<span style="color: #339933;">;</span>
    property lastname<span style="color: #339933;">;</span>
    property age<span style="color: #339933;">;</span>
    property city<span style="color: #339933;">;</span>
    property state<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>When an object is created for this CFC, you can directly call the setters and getters for the properties as </p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #000099;">    person <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">new</span> Person<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    person.setFirstName<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Brad&quot;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    person.setLastName<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Pitt&quot;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    person.setAge<span style="color: #0000FF;">&#40;</span><span style="color: #FF0000;">46</span><span style="color: #0000FF;">&#41;</span>;</span>
&nbsp;
<span style="color: #000099;">    <span style="color: #800080; font-weight: bold;">writeOutput</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Name : #person.getFirstName()# #person.getLastName()#&quot;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    <span style="color: #800080; font-weight: bold;">writeOutput</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Age : #person.getAge()#&quot;</span><span style="color: #0000FF;">&#41;</span>; </span>
<span style="color: #000099;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>The implicit setter/getter uses the &#8216;variable&#8217; scope, which is a private scope for a object, for storing the data. i.e the setter method puts the data in the variable scope and the getter method gets the data from the variable scope. </p>
<p>What if you want to override the setter/getter method? Ofcourse you can do that. You just need to define those methods in your CFC and ColdFusion will call your method instead of calling the implicit one. </p>
<p>Hmm.. What if you dont want ColdFusion to generate getter or setter or both methods for a particular property? You can disable that by adding attribute getter=&#8221;false&#8221; and setter=&#8221;false&#8221; on the property.</p>
<p>So if you define a property </p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">property name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;city&quot;</span> getter<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;false&quot;</span> setter<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;false&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>ColdFusion will not generate getCity() and setCity() methods for this CFC.</p>
<p>The implicit methods can also do some nice validation if you have given the &#8216;type&#8217; for properties. Consider the same Person.cfc with type specified where we have made age as a numeric type. </p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @accessors true
 */</span>
<span style="color: #003399;">Component</span> Person<span style="color: #009900;">&#123;</span>
    property string firstname<span style="color: #339933;">;</span>
    property string lastname<span style="color: #339933;">;</span>
    property numeric age<span style="color: #339933;">;</span>
    property string city<span style="color: #339933;">;</span>
    property string state<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>ColdFusion will do the datatype validation whenever the setter method is called for any property. So if you call</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #000099;">    person <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">new</span> Person<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    person.setFirstName<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Brad&quot;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    person.setLastName<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Pitt&quot;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    person.setAge<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;LA&quot;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>It will throw a nice error saying &#8220;The value cannot be converted to a numeric&#8221;. </p>
<p>Whats more interesting is that you can do a whole lot of validation using cfproperty. We have added two more attributes on cfproperty named <strong>&#8216;validate&#8217;</strong> and <strong>&#8216;validateparams&#8217;</strong>. These attributes allow you do even more advanced validations of the property data when the setter method is called for a property. (This is similar to cfparam or cfform validation).</p>
<p>The possible values for validate attributes are</p>
<ul>
<li>
<p>string</p>
<li>
<p>boolean</p>
<li>
<p>integer</p>
<li>
<p>numeric</p>
<li>
<p>date</p>
<li>
<p>time</p>
<li>
<p>creditcard: A 13-16 digit number conforming to the mod10 algorithm.</p>
<li>
<p>email: A valid e-mail address.</p>
<li>
<p>eurodate: A date-time value. Any date part must be in the format dd/mm/yy. The format can use /, -, or . characters as delimiters.</p>
<li>
<p>regex: Matches input against pattern specified in <samp>validateparams</samp>.</p>
<li>
<p>ssn: A U.S. social security number.</p>
<li>
<p>telephone: A standard U.S. telephone number.</p>
<li>
<p>UUID: A Home Universally Unique Identifier, formatted &#8216;XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXXXXX&#8217;, where &#8216;X&#8217; is a hexadecimal number.</p>
<li>
<p>guid: A Universally Unique Identifier of the form &#8220;XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&#8221; where &#8216;X&#8217; is a hexadecimal number</p>
<li>
<p>zipcode: U.S., 5- or 9-digit format ZIP codes</p>
</li>
</ul>
<p>The &#8216;validateparams&#8217; attribute available with <samp>&lt;cfproperty&gt;</samp> takes the parameters required by the validator specified in the &#8216;validate&#8217; attribute. This needs to be specified in the implicit struct notation. </p>
<ul>
<li>
<p>min: Minimum value if &#8216;validate&#8217; is integer/numeric/</p>
<li>
<p>max: Maximum value if the &#8216;validate&#8217; is integer/numeric/</p>
<li>
<p>minLength: Minimum length of the string if the &#8216;validate&#8217; is string</p>
<li>
<p>maxLength: Maximum length of the string if the &#8216;validate&#8217; is string</p>
<li>
<p>pattern: regex expression if the validator specified in &#8216;validate&#8217; attribute is regex</p>
</li>
</ul>
<p>Consider the Person again where we will add few more properties with some validation</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @accessors true
 */</span>
<span style="color: #003399;">Component</span> Person<span style="color: #009900;">&#123;</span>
    property string firstname<span style="color: #339933;">;</span>
    property string lastname<span style="color: #339933;">;</span>
    property numeric age<span style="color: #339933;">;</span>
    property string city<span style="color: #339933;">;</span>
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * @validate string
     * @validateparams {minLength=2, maxLength=2}
     */</span>
    property string state<span style="color: #339933;">;</span>
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * @validate zipcode
     */</span>
    property numeric zip<span style="color: #339933;">;</span>
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * @validate telephone
     */</span>
    proeprty phone<span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now when you create an object of Person and call setState(state), before setting the data for state in variable scope, ColdFusion will validate that state value provided is of type &#8217;string&#8217; and its length is 2. Similarly setZip() will validate that the input data is a valid zip code and setPhone() will validate that the input data is a valid telephone number.</p>
<p>For String type properties, you can also do regular expression validation allows you to have all sort of validation on a property of string type.</p>
<p>And to top it all, all of these nice goodies are available to you at a much lesser cost than regular UDFs. Yes, you read it right. Implicit methods perform much better than regular UDFs that you write in CFC. To confirm that, lets use this CFC where we will use implicit methods for &#8216;firstName&#8217; and write our own accessors for &#8216;lastName&#8217;.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @accessors true
 */</span>
component 
<span style="color: #009900;">&#123;</span>
    property <span style="color: #003399;">String</span> firstName<span style="color: #339933;">;</span>
    lastName <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> function setLastName<span style="color: #009900;">&#40;</span>string name<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        lastName <span style="color: #339933;">=</span> name<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> 
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> string function getLastName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> lastName<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Both implicit methods and UDFs are doing exactly the same thing i.e settings and getting the data in/from variable scope. Now lets run this comparison test</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #000099;">    person <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">new</span> Person<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    t <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">getTickCount</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    <span style="color: #0000FF;">for</span><span style="color: #0000FF;">&#40;</span>i <span style="color: #0000FF;">=</span> <span style="color: #FF0000;">0</span>; i <span style="color: #0000FF;">&amp;</span><span style="color: #0000FF;">lt</span>; <span style="color: #FF0000;">100000</span>; i++<span style="color: #0000FF;">&#41;</span></span>
<span style="color: #000099;">    <span style="color: #0000FF;">&#123;</span></span>
<span style="color: #000099;">        person.setfirstName<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Brad&quot;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">        fname <span style="color: #0000FF;">=</span> person.getFirstName<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    <span style="color: #0000FF;">&#125;</span></span>
<span style="color: #000099;">    <span style="color: #800080; font-weight: bold;">writeOutput</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Total Time in implicit methods &quot;</span> <span style="color: #0000FF;">&amp;</span> <span style="color: #0000FF;">&#40;</span><span style="color: #800080; font-weight: bold;">getTickCount</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span> - t<span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    t <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">getTickCount</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    <span style="color: #0000FF;">for</span><span style="color: #0000FF;">&#40;</span>i <span style="color: #0000FF;">=</span> <span style="color: #FF0000;">0</span>; i <span style="color: #0000FF;">&amp;</span><span style="color: #0000FF;">lt</span>; <span style="color: #FF0000;">100000</span>; i++<span style="color: #0000FF;">&#41;</span></span>
<span style="color: #000099;">    <span style="color: #0000FF;">&#123;</span></span>
<span style="color: #000099;">        person.setLastName<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Pitt&quot;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">        lname <span style="color: #0000FF;">=</span> person.getLastName<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    <span style="color: #0000FF;">&#125;</span></span>
<span style="color: #000099;">    <span style="color: #800080; font-weight: bold;">writeOutput</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Total Time in UDF methods &quot;</span> <span style="color: #0000FF;">&amp;</span> <span style="color: #0000FF;">&#40;</span><span style="color: #800080; font-weight: bold;">getTickCount</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span> - t<span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>Here is the output </p>
<p>
<pre>Total Time in implicit methods 63
Total Time in UDF methods 485</pre>
<p>Thats almost <strong>eight</strong> times faster than regular UDF. Isn&#8217;t that sweet? You get those <strong>auto-generated</strong> methods, whole lot of <strong>auto-magical validations</strong> and to top that, <strong>incredible performance</strong>. I am sure writing accessors for your CFC fields will become a thing of past now !</p>
<p><strong>Update : </strong> Post public beta, we have disabled implicit getters/setters for non-persistent CFC. To enable it, you need to set &#8220;accessors=&#8217;true&#8217;&#8221; on the component. For persistent CFC, the implicit getters/setters will always be enabled. I have changed the examples above to reflect this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-9-implicitgenerated-cfc-methods/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>A demo for ORM code generator in ColdFusion builder</title>
		<link>http://www.rupeshk.org/blog/index.php/2009/07/a-demo-for-orm-code-generator-in-coldfusion-builder/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2009/07/a-demo-for-orm-code-generator-in-coldfusion-builder/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 04:22:27 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[ORM]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[centaur]]></category>
		<category><![CDATA[orm]]></category>

		<guid isPermaLink="false">http://www.rupeshk.org/blog/index.php/2009/07/a-demo-for-orm-code-generator-in-coldfusion-builder/</guid>
		<description><![CDATA[Evelin created this nice demo that shows how to setup this &#8220;ORM code generator&#8221; extension and how to use it. Check out the demo here.
]]></description>
			<content:encoded><![CDATA[<p>Evelin created this nice demo that shows how to setup this &#8220;ORM code generator&#8221; extension and how to use it. Check out the <a href="http://blogs.adobe.com/cfbuilder/attachments/CFCGenerator4.htm">demo here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2009/07/a-demo-for-orm-code-generator-in-coldfusion-builder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion Builder : ORM code generator</title>
		<link>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-builder-orm-code-generator/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-builder-orm-code-generator/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 11:30:14 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[ORM]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[centaur]]></category>
		<category><![CDATA[orm]]></category>

		<guid isPermaLink="false">http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-builder-orm-code-generator/</guid>
		<description><![CDATA[If you have started using ORM (or you want to start) in ColdFusion 9, there is a nice plugin in ColdFusion builder that can help you quickly generate all the ORM code for you. All you do is select the tables from the RDS view, define the relationships, if there is any, and all the [...]]]></description>
			<content:encoded><![CDATA[<p>If you have started using ORM (or you want to start) in ColdFusion 9, there is a nice plugin in ColdFusion builder that can help you quickly generate all the ORM code for you. All you do is select the tables from the RDS view, define the relationships, if there is any, and all the code including the service layer will be generated. Evelin talks about it <a href="http://blogs.adobe.com/cfbuilder/2009/07/orm_cfc_generator_1.html">here</a>. Oh btw, if you did not notice, thats the <a href="http://blogs.adobe.com/cfbuilder/">ColdFusion Builder team blog</a>.</p>
<p>You can download the <a href="http://blogs.adobe.com/cfbuilder/attachments/Adobe%20CFC%20Generator.zip">plugin from here</a> and download the <a href="http://blogs.adobe.com/cfbuilder/attachments/Using%20Adobe%20CFC%20Generator.pdf">instruction from here</a>. Have Fun playing with it !!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-builder-orm-code-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion ORM and CFC Performance</title>
		<link>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-and-cfc-performance/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-and-cfc-performance/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 16:32:22 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[ORM]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[centaur]]></category>
		<category><![CDATA[orm]]></category>

		<guid isPermaLink="false">http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-and-cfc-performance/</guid>
		<description><![CDATA[Since the day we started thinking about ColdFusion ORM, people have been raising concerns over it because of the CFC performance. We have heard people saying that ORM will be unusable because of poor CFC performance and it is a stupid idea to implement CFC based ORM. And today I heard Hal Helms and Brian [...]]]></description>
			<content:encoded><![CDATA[<p>Since the day we started thinking about ColdFusion ORM, people have been raising concerns over it because of the CFC performance. We have heard people saying that ORM will be unusable because of poor CFC performance and it is a stupid idea to implement CFC based ORM. And today I heard <a href="http://www.halhelms.com/blog/index.cfm/2009/7/14/ColdFusion-and-OOP--A-Match-Made-in-Heaven-or-a-Long-Road-to-Hell">Hal Helms and Brian kotek talking about it</a> where Hal says that he shudders at the thought of hibernate integration in CF because of poor performance.</p>
<p>It is true that CFC performance is poor as compared to POJO and it will always be. ColdFusion CFC has lot of cost involved because of the dyanmic nature of it and additionally, it has reflection cost involved. I had shared some of the reasons with few of the community members and I thought it will be interesting to share it with a wider audience. Here are the main reasons :</p>
<ol>
<li>Unlike java where the class has a fully qualified name and is loaded only once in the classloader, when you create CFC, CF needs to search for the CFC file on the disk, compute the class name for it and then load it. And that happens on each object creation unless you have switched on trusted cache .
<li>CFC&nbsp; is compiled at runtime, loaded and constructed using reflection. I am sure you will be aware that reflection is much slower (25 times easily) than direct invocation in java.
<li>CFC has two different scopes &#8211; this and variables scope which is a struct. So every object creation involves two additional struct creation cost.
<li>CFC creation also involves running the default constructor i.e any code outside cffunction and that happens for each object creation. That involves the complete setup for method invocation i.e setting up localscope, superscope etc (another two structs here), which is also significant
<li>CFC allows UDFs to be added/removed from the object at runtime and hence methods are added to each object on object creation and that too in both the scopes (adding each UDFs in both the scopes also has significant cost). Thats the reason why object creation becomes costlier as you add methods in the CFC. Higher the number of methods, higher the object creation cost.</li>
</ol>
<p>We have done a lot of performance improvements regarding CFC creation and invocation in ColdFusion 9 which I hope you would have noticed. But even then it can not match POJO performance and thats an unrealistic target.</p>
<p>So given that, lets come to the question &#8211; How much does CFC creation performance matters when it comes to ORM. In reality, not much. We have done a number of performance comparison between CFC and POJO with hibernate keeping everything else absolutely same. And all the time, CFC performance was same or better than POJO persistence. It might sound unbelievable and in fact I also could not believe it myself when I saw the performance numbers first. But that is the truth. And here is why it happens &#8211; When it comes to persistence, the time taken in DB operation and the persistence layer is much more than the time taken in object creation. And that cost is same for POJO and CFC. So the only difference in cost between CFC and POJO with respect to ORM is object creation cost and cost of populating/fetching the properties data. For instantiating POJO object and for using properties accessors, Hibernate has to use reflection which is always costly and that removes this cost difference of CFC and POJO. And for few of the runs, CFC was able to beat POJO as well and explanation for that is the optimizations that we have done in using accessors for properties.</p>
<p>I would be curious to know about your experience regarding CF-ORM performance and CFC performance in general. How has your experience been so far regarding CF-ORM peformance?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-and-cfc-performance/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>ColdFusion ORM : The basics</title>
		<link>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-the-basics/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-the-basics/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 13:48:33 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[ORM]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[centaur]]></category>
		<category><![CDATA[orm]]></category>

		<guid isPermaLink="false">http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-the-basics/</guid>
		<description><![CDATA[Before starting on the advanced topics, I thought it will be better to build some ground and hence I decided to do a post on the ORM basics. In this post, we will build a simple example to get a taste of ColdFusion ORM (CF-ORM) and during that we will also understand some of the [...]]]></description>
			<content:encoded><![CDATA[<p>Before starting on the advanced topics, I thought it will be better to build some ground and hence I decided to do a post on the ORM basics. In this post, we will build a simple example to get a taste of ColdFusion ORM (CF-ORM) and during that we will also understand some of the basic concepts.
<p>ORM is <strong>object</strong> relational mapping and in ColdFusion, objects are created using CFC. CFCs that needs to be persisted are called persistent CFC and that is marked by setting &#8216;persistent&#8217; attribute to true on the component. We also need to define what persistent fields will be there in a persistent CFC and that is defined using &#8216;cfproperty&#8217;. A field/property is marked persistent by setting persistent attribute to true on the cfproperty. By default, if the CFC is persistent, all its properties are considered as persistent unless you mark a property non-persistent. So typically &#8216;persistent&#8217; attribute on the property is used only when you need to make that property non-persistent.
<p>Each persistent CFC in ColdFusion application maps to a table in the database and each property in the persistent CFC maps to a column in the table (not exactly true but we will come to that later.. For the time being lets keep it that way). We will use the cfartgallery datasource for this example which has Artists and Art tables.
<p>The first thing you need to do is &#8211; enable ORM for the application and define a datasource to be used (What is an ORM without a datasource?). ColdFusion ORM uses Application.cfc to define all the ORM specific settings. (If you haven&#8217;t started using Application.cfc for your application, its time to start using it!)
<p><strong>Application.cfc</strong> </p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">Component</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">name</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;ArtGallery&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">ormenabled</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;true&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">datasource</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cfartgallery&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Note that the datasource setting defined here makes it the default datasource of your application which can be used by tags like cfquery, cfinsert, cfupdate, cfdbinfo. The same default datasource will be used by ORM as well. </p>
<p>There are a whole bunch of <a href="http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSED380324-6CBE-47cb-9E5E-26B66ACA9E81.html">ORM related configuration</a> that you can do in application.cfc which you can refer <a href="http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSED380324-6CBE-47cb-9E5E-26B66ACA9E81.html">here</a>. </p>
<p>Now that the application is configured, let us build the object and define the persistence information on it. To start with, we will first define the Artist.cfc
<pre><strong>Artists.cfc</strong></pre>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @persistent
 */</span>
<span style="color: #003399;">Component</span> <span style="color: #009900;">&#123;</span>
    property name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;artistid&quot;</span> generator<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;increment&quot;</span><span style="color: #339933;">;</span>
    property firstname<span style="color: #339933;">;</span>
    property lastname<span style="color: #339933;">;</span>   
    property address<span style="color: #339933;">;</span>
    property city<span style="color: #339933;">;</span>
    property state<span style="color: #339933;">;</span>
    property postalcode<span style="color: #339933;">;</span>
    property email<span style="color: #339933;">;</span>
    property phone<span style="color: #339933;">;</span>         
    property fax<span style="color: #339933;">;</span>
    property thepassword<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This is the most simplistic definition of the component where we have defined only the component and its properties names. Since the table for this CFC already exists in the database, we have not added any table specific information in this and we will let ORM infer all the information from the database. The only additional setting that we have added here is the &#8216;generator&#8217; attribute which is used to auto-generate the primary key.</p>
<p>After the components are defined, the first request to this application (i.e a page in this application) will make CF-ORM do all the setup necessary (basically generation of hibernate configuration, mapping files, building the session factory etc). Once the setup is done, you are all set to work with the entities.</p>
<p>We will first list all the artists and here is what you need to do for that</p>
<p><strong>listAll.cfm</strong></p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #000099;">   artists <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">EntityLoad</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Artists&quot;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">   <span style="color: #800080; font-weight: bold;">writedump</span><span style="color: #0000FF;">&#40;</span>artists<span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>To load a particular Artists with its ID, here is what you do</p>
<p>&nbsp;<strong>list.cfm</p>
<p></strong></p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #000099;">   artist <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">EntityLoadByPK</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Artists&quot;</span>, <span style="color: #FF0000;">1</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">   <span style="color: #800080; font-weight: bold;">writedump</span><span style="color: #0000FF;">&#40;</span>artist<span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>There are several flavors of EntityLoad functions details of which can be read <a href="http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WS02BE9BC5-8206-434b-8486-95CD09CDB985.html#WSf01dbd23413dda0e54af3c7912012f78097-7ff8">here</a></p>
<p>Let us now see how to perform insert and update on it.</p>
<p><strong>save.cfm</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;&lt;</span><span style="color: #000000;">br</span><span style="color: #0000FF;">&gt;</span>   <span style="color: #808080; font-style: italic;">// Insert a new artist</span></span>
<span style="color: #000099;">   artist <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">new</span> Artists<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">   artist.setfirstname<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Leonardo&quot;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">   artist.setlastname<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Da vinci&quot;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">   artist.setcity<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Paris&quot;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">   <span style="color: #800080; font-weight: bold;">EntitySave</span><span style="color: #0000FF;">&#40;</span>artist<span style="color: #0000FF;">&#41;</span>;</span>
&nbsp;
<span style="color: #000099;">   <span style="color: #800080; font-weight: bold;">writeOutput</span><span style="color: #0000FF;">&#40;</span>artist.getartistid<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&#41;</span>;<span style="color: #808080; font-style: italic;">// Update an artist</span></span>
<span style="color: #000099;">   artist <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">EntityLoadByPK</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Artists&quot;</span>, <span style="color: #FF0000;">2</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">   artist.setcity<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;NewYork&quot;</span><span style="color: #0000FF;">&#41;</span>; <span style="color: #808080; font-style: italic;">// artist is automatically updated.</span></span>
<span style="color: #000099;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span></pre></td></tr></table></div>

<p>As we see in the above example, EntitySave is used to insert/update an object in the table. There are some important things to note here</p>
<ul>
<li>EntitySave is an intelligent function which automatically finds if a new row needs to be inserted for the given object or whether an existing row needs to be updated.
<li>We called EntitySave for the insert here but not for update but even then artist &#8216;2&#8242; gets updated. So how did that happen? Actually what happens here is when you load an artist object, it becomes associated with the hibernate session which keeps track of any changes in the object and automatically saves it when the session is flushed. We will talk about more about hibernate session in a later post. For the time being lets just say that Hibernate Session is a short-lived object that represents a conversation between the application and the persistence layer and also acts as the first level of cache.
<li>We did not write any setter or getter method for artist&#8217;s properties in Artists.cfc but we are calling them here. That works because ColdFusion 9 automatically generates accessor methods for any property written in a CFC. More details on generated methods in a later post.
<li>At line no 6, we called entitySave, but if you check the database, the row is not inserted yet. So when does that happen? Hibernate batches up all the operations till the end of the request or to be exact till hibernate session is flushed. ColdFusion ORM starts up a session when the first ORM method is called in the request and is automatically flushed when the request ends. The batching is done for performance reason so that hibernate executes the sql with the final state of the objects. It will be a huge performance bottleneck if ORM keeps executing sql for each changes in the object.</li>
</ul>
<p>To delete an Artist, you need to call EntityDelete() passing the object to be deleted. </p>
<p><strong>delete.cfm</strong></p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #000099;">    artist <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">EntityLoadByPK</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;Artists&quot;</span>, <span style="color: #FF0000;">15</span>, true<span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    <span style="color: #800080; font-weight: bold;">EntityDelete</span><span style="color: #0000FF;">&#40;</span>artist<span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<h4>Relationship</h4>
<p>So far we have seen how to perform CRUD for a single entity. But in any application, there will be entities which are associated and ORM must load the associated object as well when loading a particular entity. For our example, an Art will have an Artist and when loading the art object, it should also load the associated artist. So lets build the model first after which we will see how to work with the association.</p>
<p>In cfartgallery, the table Artists has a one-to-many relationship with Art table, which are joined using the foreign key column ARTISTSID. This means that each artist has created multiple arts and each art is created by one artist. To represent this in the object model, each ARTIST object would contain an array of ART objects. Each ART object will also contain a reference to its ARTIST object thereby forming a bidirectional relation. </p>
<p>To achieve this, we will need to add an extra property &#8216;arts&#8217; to &#8216;Artists&#8217; that contains an array of ART objects for that Artist. The modified Artists.cfc would look like</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @persistent
 */</span>
<span style="color: #003399;">Component</span> <span style="color: #009900;">&#123;</span>
    property name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;artistid&quot;</span> generator<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;increment&quot;</span><span style="color: #339933;">;</span>
    property firstname<span style="color: #339933;">;</span>
    property lastname<span style="color: #339933;">;</span>   
    property address<span style="color: #339933;">;</span>
    property city<span style="color: #339933;">;</span>
    property state<span style="color: #339933;">;</span>
    property postalcode<span style="color: #339933;">;</span>
    property email<span style="color: #339933;">;</span>
    property phone<span style="color: #339933;">;</span>         
    property fax<span style="color: #339933;">;</span>
    property thepassword<span style="color: #339933;">;</span>
    property name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;arts&quot;</span> fieldtype<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;one-to-many&quot;</span> fkcolumn<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;artistid&quot;</span> cfc<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Art&quot;</span> cascade<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;all&quot;</span> inverse<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;true&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Here is the <strong>Art.cfc</strong> </p>
<p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @persistent
 */</span>
<span style="color: #003399;">Component</span> <span style="color: #009900;">&#123;</span>
    property name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;artid&quot;</span> generator<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;increment&quot;</span><span style="color: #339933;">;</span>
    property artname<span style="color: #339933;">;</span>
    property price<span style="color: #339933;">;</span>
    property largeimage<span style="color: #339933;">;</span>
    property mediaid<span style="color: #339933;">;</span>
    property issold<span style="color: #339933;">;</span>
    property name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;artist&quot;</span> fieldtype<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;many-to-one&quot;</span> fkcolumn<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;artistid&quot;</span> cfc<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Artists&quot;</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Notice the artist property above which is of many-to-one type. Also notice that both the property use the same value for fkcolumn attribute i.e &#8216;artistid&#8217; of Art table that references artistID pk of Artist table. </p>
<p>Since we have added a new persistent CFC (Art.cfc) after the application was loaded, we need to re-initialize the ORM for this application so that mappings for Art.cfc also gets generated. This can be done by calling ORMReload() method. There are some nice ways to do this but for the time being lets keep it simple by putting this in a separate page which we will call to reload ORM.</p>
<p><strong>initializeORM.cfm</strong></p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> <span style="color: #800080; font-weight: bold;">ormReload</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>If you load and dump Artist (using listAll.cfm), you should also see the associated art objects for artists.</p>
<p>Now let us create a new Art and associate it with an existing Artist.</p>
<p>artCreate.cfm</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #000099;">    artist <span style="color: #0000FF;">=</span> <span style="color: #800080; font-weight: bold;">EntityLoad</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;artists&quot;</span>, <span style="color: #FF0000;">1</span> ,<span style="color: #009900;">&quot;true&quot;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    art <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">new</span> Art<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    art.setartname<span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;landscape&quot;</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    art.setPrice<span style="color: #0000FF;">&#40;</span><span style="color: #FF0000;">1500</span><span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    art.setissold<span style="color: #0000FF;">&#40;</span>false<span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    art.setartist<span style="color: #0000FF;">&#40;</span>artist<span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    artist.addArts<span style="color: #0000FF;">&#40;</span>art<span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;">    <span style="color: #800080; font-weight: bold;">EntitySave</span><span style="color: #0000FF;">&#40;</span>art<span style="color: #0000FF;">&#41;</span>;</span>
<span style="color: #000099;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span></pre></td></tr></table></div>

<p>If you notice line 7-8 above, we associate artist to art by calling art.setArtist(artist) as well as art to artist by calling artist.addArts(art). Hibernate needs us to do this in order to set up the bidirectional relation properly. Since it is a bidirectional relation, you must also decide which side will set the relation in the database. i.e which side of the relation will set the fkcolumn in the table. This is controlled by the &#8220;inverse&#8221; attribute of proeprty, which if set to true, tells hibernate that this is a inverse of the other relation and this side of relation should be ignored for persistance. If you don&#8217;t set inverse to true, Hibernate will unnecessarily fire two sqls for the same association. </p>
<p>So there you have it. We have seen how you can use ORM to perform the basic CRUD operations on entities. For more details, you can refer to the <a href="http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSD628ADC4-A5F7-4079-99E0-FD725BE9B4BD.html">ORM doc</a> and <a href="http://docs.jboss.org/hibernate/stable/core/reference/en/html_single/">Hibernate docs</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-orm-the-basics/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>ColdFusion 9 and ColdFusion builder beta available</title>
		<link>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-9-and-coldfusion-builder-beta-available/</link>
		<comments>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-9-and-coldfusion-builder-beta-available/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 05:48:31 +0000</pubDate>
		<dc:creator>Rupesh Kumar</dc:creator>
				<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[centaur]]></category>

		<guid isPermaLink="false">http://www.rupeshk.org/blog/index.php/2009/07/12/coldfusion-9-and-coldfusion-builder-beta-available/</guid>
		<description><![CDATA[I am sure by the time you will be reading this, the blogosphere will be buzzing with this news  . We just (13th July 12:01 AM EST) went live with the beta of ColdFusion 9 and ColdFusion builder. All of us in the team had been working really hard for last one and half [...]]]></description>
			<content:encoded><![CDATA[<p>I am sure by the time you will be reading this, the blogosphere will be buzzing with this news <img src='http://www.rupeshk.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . We just (13th July 12:01 AM EST) went live with the beta of ColdFusion 9 and ColdFusion builder. All of us in the team had been working really hard for last one and half years to put in features, that will take RAD to the next level, features that will make your life easy, features that you are going to love. ColdFusion has always been known for &#8220;making hard things easy&#8221; and I am sure this release will make even harder things easy <img src='http://www.rupeshk.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Ben talked about the new features in <a href="http://labs.adobe.com/technologies/coldfusion9/">ColdFusion 9</a> and <a href="http://labs.adobe.com/technologies/coldfusionbuilder/">ColdFusion beta</a> here :</p>
<p><a title="http://www.adobe.com/devnet/coldfusion/articles/coldfusion9_whatsnew.html" href="http://www.adobe.com/devnet/coldfusion/articles/coldfusion9_whatsnew.html">http://www.adobe.com/devnet/coldfusion/articles/coldfusion9_whatsnew.html</a></p>
<p><a title="http://www.adobe.com/devnet/coldfusion/articles/cfbuilder_whatsnew.html" href="http://www.adobe.com/devnet/coldfusion/articles/cfbuilder_whatsnew.html">http://www.adobe.com/devnet/coldfusion/articles/cfbuilder_whatsnew.html</a></p>
<p>Here are the links for public beta</p>
<p>ColdFusion 9 : <a title="Hhttp://labs.adobe.com/technologies/coldfusion9/" href="http://labs.adobe.com/technologies/coldfusion9/">http://labs.adobe.com/technologies/coldfusion9/</a></p>
<p>ColdFusion Builder : <a title="Hhttp://labs.adobe.com/technologies/coldfusionbuilder/" href="http://labs.adobe.com/technologies/coldfusionbuilder/">http://labs.adobe.com/technologies/coldfusionbuilder/</a></p>
<p>I also wanted to highlight an excellent devnet article written by Mark Mandel <a href="http://www.adobe.com/devnet/coldfusion/articles/coldfusion9_orm.html">introducing ColdFusion ORM</a>. I am sure ColdFusion ORM is going to completely change the way ColdFusion applications are built and is going to make you much more productive. Hey, I am not boasting because its my baby, but I genuinely feel this <img src='http://www.rupeshk.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rupeshk.org/blog/index.php/2009/07/coldfusion-9-and-coldfusion-builder-beta-available/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
