[coldbox 3.7.0; cf10; mysql] - handling NULLABLE float with Orm Services

I have an object which contains prices. The table column type for these properties is ‘Float’. The columns are nullable.

One of these properties is “priceNonMember”.

When I run the following:


Where priceNonMember is included in arguments, but is empty, I receive the following error:

Error Type: Application : [N/A]
Error Messages: Property : priceNonMember - The value ‘’ cannot be converted to a number.
Root cause :org.hibernate.HibernateException: Property : priceNonMember - The value ‘’ cannot be converted to a number.

Is it possible for Orm Services to handle Nullable float properties?

Many Thanks


Hi Jason–

Does arguments contain a key for “priceNonMember”? If so, you might add the ignoreEmpty=true argument to your call to populate(). This will prevent that key from being processed when the populate runs. Alternatively, you can simply exclude that property from the argument collection, and it should accomplish the same thing.

I, personally, haven’t found one on the populate methods and javacast() will set empty interferes and floats to 0.

What I have done is run my structure (eg - the request collection) through a method that removes the nulls numerics/floats/empty bits from the structure passed.

For example:
event = populateModel(“event”, filterProperties(event.getCollection()));


Joel, ignoreEmpty=true is exactly what I was looking for… that did the trick perfectly.



Jason, out of curiosity is there any reason why you don’t set the default to 0.00 when the column is added to the DB not passed via an SQL?

@Jason-- Awesome, glad it worked.
@Andrew – In this scenario, a default value on the DB doesn’t matter since the error was occurring in the populate().

Yes I realise that Joel, I wanted to know why some people don’t include defaults in their ORM like this.

Can’t speak for Jason’s business requirements, but I would imagine it’s because it’s a “price” related field. Big difference between a NULL and a price of 0.00!

Hi Joel, the price field is an optional value in a form.

From the clients perspective $0 indicates it is worth $0 (free), which is different to ‘no price’. This makes sense to me as well. $0 is different to ‘no price’.

Sorry…I meant last post to Andrew…

Thanks, Jason sometimes I can assume, but it is always nice to ask to clarify.

I’ve hit a snag with this one.

If I set ignoreEmpty=true, there is now no way for the user to clear a field in the form that is populating the model via the populate method with ignoreEmpty=true. For example, there is a field in the form that is passed in to populate the model called “venue”. If the user decides to empty this, and clears the text from the field, then submits the form, it doesn’t clear the text because the populate method is now ignoring that empty field.

Can anyone suggest a way around this? The only thing I can think of is to set the default value to ‘0’ for the float values after all… then having to handle this in my views…


Try nullEmptyInclude. You can pass a list of properties that should be nulled when an empty string is passed.

Worked perfectly! Thank you!

Awesome, glad it did the trick!