Storing ORM Entities in the session scope
I've just been trying to debug an error with ColdFusion ORM. I'm currently building a multi-step booking system and decided to store the new Booking Entity in the ColdFusion session scope until the final stage of the process at which point I'd call EntitySave. Normally I'd only store the id in the ColdFusion session scope and retrieve the Entity on each request, but I didn't want to populate my database with partial booking data.
When I was calling EntitySave, ColdFusion was throwing the following error:
Root cause :org.hibernate.HibernateException: coldfusion.runtime.Cast$NumberConversionException: The value '' cannot be converted to a number.
If created a new Entity and populated it with the data from my Entity stored in the ColdFusion Session scope then it saved as expected. It took me a while to figure out that when ColdFusion saves the entity in session scope, it doesn't seem to preserve the null values and instead, substitutes them for an empty string. As a result my id value was not null. To solve it all I had to do was explictly set the id to null prior to calling EntitySave.
- Posted in:
- ColdFusion
- Hibernate


Comment by Jeff – December 13, 2011