[coldbox 3.8.0 / cf10] Can't seem to chain Criteria Builider methods

Can anyone tell me why this isn’t working? From what I can tell, I have followed example exactly as per documentation, but get the below error:

`
i = orm.newCriteria(“Invoice”);

var invoices = i.eq(‘orgID’,i.convertValueToJavaType(‘orgID’,Application.orgID))
.and(
i.restrictions.ge(‘invoiceDate’,dateHelper.formToCF(arguments.fromDate))
)
.list();
`

ERRO

`
Error Type: Template : [N/A]
Error Messages: Invalid CFML construct found on line 70 at column 34.
ColdFusion was looking at the following text:

and

The CFML compiler was processing:
`

If I remove the .and() method, it runs fine, but when I add another method or restriction [eg .and() or .ge()] I get an error that the method doesn’t exist.

This works fine:

`
i = orm.newCriteria(“Invoice”);

var invoices = i.eq(‘orgID’,i.convertValueToJavaType(‘orgID’,Application.orgID)).list();

`

Anything obvious I am doing wrong to prevent ability to chain criteria?

Many Thanks in advance.

Jason

CF10’s parser is buggy since “and” is a reserved word. use $and() instead. (See coldbox/system/orm/hibernate/criterion/restrictions.cfc

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

PERFECT! Thanks Brad.

Will this still work if I ever try to run this on Railo (which is a hope). Thanks!

Here is my (now) working code.

`

var invoices = i.eq(‘orgID’,i.convertValueToJavaType(‘orgID’,Application.orgID))
.$and(
i.restrictions.ge(‘invoiceDate’,dateHelper.formToCF(arguments.fromDate)) i.restrictions.le(‘invoiceDate’,dateHelper.formToCF(arguments.toDate))
)
.list();

`

If I recall, both versions work on Railo. It’s parser is smart enough to figure out it’s a method call.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Is it appropriate to also use .conjunction() by rearranging the criteria a bit? I ran into the same problem on CF9 and wasn’t aware of the $and – so thank you!

Wes