Aliaspooryorik
ColdFusion ORM Book

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.


1 comment

  1. Thanks for the post. I just ran into this.

    Comment by Jeff – December 13, 2011

Leave a comment

If you found this post useful, interesting or just plain wrong, let me know - I like feedback :)

Please note: If you haven't commented before, then your comments will be moderated before they are displayed.

Please subscribe me to any further comments
 

Search

Wish List

Found something helpful & want to say ’thanks‘? Then visit my Amazon Wish List :)

Categories

Recent Posts