I was working more with ColdFusion 9 ORM and found another small caveat I thought I would share. When working with a relationship that is filtered, the implicit "has[property]", the has does not take into account the filter. The implicit get works as expected however.
UPDATE: This is only an issue with a lazy loaded property. Thanks Ben Nadel for pointing it out.
Consider the following persistent cfc...
<cfcomponent hint="I am the Album cfc" output="false" persistent="true" table="Albums">
<!--- CFC ID --->
<cfproperty name="AlbumID" type="numeric" fieldtype="id" />
<!--- Relationships --->
<cfproperty name="Photos" lazy="true" type="array" singularname="Photo" fkcolumn="AlbumID" orderby="Ind" fieldtype="one-to-many" cfc="Photo" inverse="false" where="DisplayPhoto='true'" />
<!--- Properties --->
<cfproperty name="AlbumName" type="string" />
<cfproperty name="AlbumCover" type="string" />
<cfproperty name="Ind" type="numeric" />
<!--- Functions --->
First, notice that I have the cfc divided into four sections, the CFC ID, any relationships, any other properties of the cfc, and finally any additional functions. I feel this is a handy way to organize your ORM cfc's. I find that I need to refer to the ID and the relationships often, so I put them towards the top.
OK, but onto the issue we are talking about. Notice the relationship to that this CFC has to Photos is filtered with a where attribute of DisplayPhoto='true'. This will return only the Photos that have the DisplayPhoto flag set to true and works perfect when we call the implicit getPhotos() method. However, the hasPhoto() method does not take the where clause into account. So, if we have an Album with lots of photos where they are all have the DisplayPhoto flag set to false, the implicit method would still return true. To workaround this issue I wrote my own has function.
<cffunction name="hasPhoto" access="public" returntype="boolean" output="false">
<cfset var qry = queryNew("blah") />
<cfset var has = false />
select count(PhotoID) as count from Photos where AlbumID = <cfqueryparam value="#this.getAlbumID()#">
and DiplayPhoto = 'true'
<cfif qry.count GT 0>
<cfset has = true />
<cfreturn has />