[coldbox-5.6.2] [cborm-2.3.0] Disjunction - cast to string when the type is double.

Just getting into to CBORM / HQL and I’ve used my first disjunction to OR together some AND restrictions.

I am looping over my form fields to build an array for the disjunction:

`

arrayAppend(arrRestrictions, hql.restrictions.and(
hql.restrictions.eq(“JobTypeCategoryDimension.JobTypeCategoryDimensionID”, rc.arrayDimensions[n]),
hql.restrictions.eq(“ProductAttributes.AttributeValue”, javaCast(“double”, rc.arrayMillimetres[n]))
))

`

And then

`


.disjunction(
arrRestrictions
)

`

…but I got the error message:

java.lang.Double cannot be cast to java.lang.String

ProductAttributes.AttributeValue is stored (MS SQL) as a decimal.

Changing the last part to:
javaCast(“string”, rc.arrayMillimetres[n])

…seems to have resolved the issue.

But I don’t understand why? Do all restrictions need to be cast to string? Or is this just ‘luck’ and I’m not actually doing it right?

I would use the autoCast() feature instead and let hibernate deal with it. Look at the docs for that function, it’s a life saver