[ColdBox 3.8.1] Find a children in many-to-many relationship by column

I want to know what is the best approach to find if an object has a children that has a value in a clumn.

I have this relationship User.cfc:

`

property name=“sites” singularName=“site” notnull=“true” fieldtype=“many-to-many” type=“array” lazy=“extra”
cfc=“Site” fkcolumn=“FK_siteID” linktable=“userSites” inversejoincolumn=“FK_userID”;

`

Site.cfc

`

// Properties
property name=“siteID” fieldtype=“id” generator=“native” setter=“false”;
property name=“siteUrl” length=“100” notnull=“true”;

`

Now I have my domain name “mydomain.com” and wanna know if a user has a relationship with this site.

How can if user has a site that has siteUrl = “mydomain.com”?

I should use userService.findIt(“from User as u where u.FK_siteID=‘mydomain.com’”);

I should go with criteriabuilder?

Criteria builder would be much easier

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
P/F: 1-888-557-8057
Direct: (909) 248-3408

ColdBox Platform: http://www.coldbox.org

ContentBox Platform: http://www.gocontentbox.org
Linked In: http://www.linkedin.com/pub/3/731/483

Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano | twitter.com/gocontentbox