Hibernation Humiliation

In ColdFusion 9.0, there was a serious issue, in my opinion, with the way the Hibernate session was managed during transactions. ColdFusion would flush and close an existing session when you started a transaction, and would also close an existing session when a transaction ended, whether via a commit or a rollback. This has been improved in ColdFusion 9.0.1.

from Bob’s Blog, from the mighty Bob Silverberg.  BIG clue there.

Also, in the google cf-orm-dev forum, Marc Esher says:

seth, to be clear, if you use transaction{}, you don’t need to ormflush().

Dustin, autoManageSession=true will be especially problematic in cases where you populate your objects, then pass them through some validation routine (either homegrown or otherwise), and then, depending on whether the object validates, then save the object.

with autoManageSession=true, by virtue of modifying those objects, even if they’re not valid, hibernate’s going to flush that session. So it’s going to save objects that you don’t want to have saved.

if you use autoManageSession=false,  then YOU control that.

so you can populate your objects, validate, then then do something like:

if( validated ){
transaction{
entitySave(object);

Once again, it would have been nice to know this limitation of 9.0.0 from the start.  Just think how many more are lurking.

Here’s the problem I’m having.  When my app is pointed to a date it hasn’t covered before, there are no days for that week in the database, and it must create them.  What it’s doing now is creating multiple copies of some days, which causes the db to puke over having multiple records with the same key.

Looks like I’m off to Transaction Land.

Advertisements

About blippoids

Enough about me.
This entry was posted in ColdFusion, ORM. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s