开发者

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

Jo开发者_运维技巧hn     Blonde

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

  • What will happen the next time a page tries to list John's hair color?
  • Assuming the hair color is still showing as blonde because it was cached, how can one flush that cache?
  • Assuming the hair color is still cached as blonde, what happens if I change John's name to Jonathon using CF ORM? Will it overwrite the hair color back to blonde when it updates the row?
  • Similarly, what if I try to update the hair color to green using CF ORM? Will CF check and notice that it's cached value (blonde) is no longer the current value (black) and give some kind of feedback?

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.


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.


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

see:

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜