ColdFusion v Railo ORM
I've been working on an ColdFusion 9.01 ORM application so that it also runs on Railo 3.3.1 and found a few differences which I thought I'd blog in case it helps anyone else.
The biggest one for me is that Railo does not support automatic dirty checking.
This means that if I have an application which is setup so that the ormsettings.flushatrequest setting is false (which I think everyone agrees is the best practice). Then this code in ACF will save the modified persistent Entity, in Railo it will not.
transaction
{
Foo = EntityLoadByPK( "Foo", 1 );
Foo.setBar( "ABC123" );
}
In ColdFusion, closing the transaction will cause any "dirty" entities to be committed to the database. This is the normal behaviour in Hibernate. Railo does not commit the changes at all.
To make it work in Railo is pretty simple, just add an EntitySave call (EntitySave is only required to save non-persisted entities in ACF). So the code now looks like:
transaction
{
Foo = EntityLoadByPK( "Foo", 1 );
Foo.setBar( "ABC123" );
EntitySave( Foo );
}
You could also use ORMFlush() to force the changes to be commited but I think EntitySave is a much better approach as ORMFlush() will cause any dirty entities in the session to be committed. You can view my ticket here.
Another thing I found was that in Railo you don't need to specify the full path to other entities for relationships. For example in ACF I need to do this to map a relationship between two entities in different packages (folders).
property name="bars" fieldtype="one-to-many" cfc="model.foo.bars";
In Railo I can do this:
property name="bars" fieldtype="one-to-many" cfc="bars";
This makes a lot of sense to me as entity names are unique and EntityLoad etc don't require the full path, however, if you had a complex application I would probably put the full path in for clarity.
I did also have some issues with passing entities into HQL queries but the tickets I raised seem to be fixed now.
Looking through the other tickets on the Railo bugtracker, there are some other incompatibilities, such as multiple datasources and embedded mappings, but the Railo guys do seem to be pretty quick at resolving issues.
- Posted in:
- ColdFusion
- Railo
- Hibernate


Comment by John Farrar – December 22, 2011
Saving non persistant entities? Can you clarify this a bit?
Comment by John Allen – December 22, 2011
Comment by John Farrar – December 22, 2011
By 'non-persistent' I think John is referring to an object that has not yet been saved to the database.
Comment by Simon Bingham – December 22, 2011
@John A, sorry for not being clear. By "persistent entity" I mean an entity that has been retrieved from the database (via ORM), a non-persistent entity is one that is new and hasn't (yet) been committed to the database.
Comment by John Whish – December 22, 2011