Use Entities Rather Than Their Keys in CFQL
CFQL is made to use entities directly, you don’t have to use their keys explicitly (even though you can). The key point in CFQL is to be decoupled from the database’s physical definition, so keep it as simple as possible using entities for maximum flexibility. Here’s an example illustrating this point. One could be tempted to write such a CFQL query:
<cf:method name="DeleteByRoleId" body="delete(int RoleId) where Role.Id=@RoleId " />
Of course, this method is valid, however writing so implies that the identifier of the Role entity is of the integer type, so if you change its type, or change its key into a composite key, you’ll have to write this method over. However, using entities directly instead of their keys solves this issue:
<cf:method name="DeleteByRole" body="delete(Role) where Role=@Role" />
Both CFQL queries will actually produce the same SQL statement, however the second version is way more flexible.