Nicholas
Nicholas

Reputation: 95

How does ColdFusion ORM deal with changes made outside of ORM

I've just begun learning about ColdFusion ORM and persistent cfcs and how it can improve application performance. I'm still working on gaining a full understanding before trying to implement anything on my own sites, but there's one question I can't seem to find the answer to anywhere.

I understand that much of the performance increase comes from batching database CRUD in a single transaction at the end of a page, and from intelligent caching of select statements. Regarding the latter, how does this caching work and, more specifically, how does it deal with changes made outside of the ColdFusion application.

For instance, suppose I have a users table that looks like the following:

Name   Hair

Nick      Brown

John     Blonde

Now suppose that I run a simple update query through PL/SQL Developer to update John's hair color to black. Now...

Just as importantly (maybe more importantly), what are the answers to those same questions if a CFQuery is used to update John's hair color instead of an external program. In other words, can CFQuery be safely used on an ORM managed table?

I tried reviewing CF's documentation, Hibernate's documentation, and a variety of online blogs, but information on ORM's caching and how it interacts with other database manipulation methods (CFQuery, PL/SQL Developer, etc) is lacking. Any help would be appreciated.

Thanks.

Upvotes: 3

Views: 467

Answers (3)

Sam Farmer
Sam Farmer

Reputation: 4118

The basic "caching" and I quote that because its more of a Hibernate session that lasts as long as a ColdFusion request. Lets look at the following workflow:

ColdFusion request starts and changes Nicks hair to Red. Request finishes.

In an SQL editor run SELECT * ... and the color is Red. Use update and change it to Blond.

A new ColdFusion request and gets the color of the Nicks hair via ORM, that value is Blond.

Basically, as Marc says, when you not using the secondary cache the values are always what comes from the database and work fine.

Upvotes: 2

marc esher
marc esher

Reputation: 4921

It's been my experience that in most cases -- when the cache is not involved -- things work just fine. However, I have some scripts that wipe out and reinsert a bunch of data as part of migrations. In those instances, ORMReload() does not work, and I have to restart ColdFusion. The tell-tale sign when this happens is that I'll get a "update failed. Expected 1, received 0" error from CF.

Upvotes: 1

Henry
Henry

Reputation: 32885

If you update the cached data externally, you will have to evict cache yourself.

see:

ormEvictCollection(), ormEvictEntity(), and ormEvictQueries()

Upvotes: 2

Related Questions