views:

46

answers:

2

How to cache rarely changed many-to-one entity in CF ORM, such as, userType where there are only < 10 types? I don't want the extra select to get the type name.

EhCache? Any XML needed to be config first? Any thing I need to add in the many-to-one cfproperty?

Thank you.

A: 

Add this to your many-to-many to force it to load the children when populating the entity.

   lazy="false"
jarofclay
thx, but that's not what i'm looking for, I DO need the type name, just that I don't want the select to be fired.
Henry
+1  A: 

If UserType is a component, you specify cacheuse="read-only" cachename="UserType" in the component definition. read-only is the fastest and is good for cases such as the one you describe.

In my experience, simply specifying the cache value on the property in the owning component did not cause the caching that you'd expect... I needed to specify it directly on the component-being-cached

Because you're using read-only for speed, you'll need something somewhere to let you evict that cache when data are updated:

ormEvictEntity("UserType");

marc esher
Oh, Henry, no need to configure any XML. It "Just works" when you add those component attributes
marc esher
really? I thought there's some XML for enabling level 2 cache for Hibernate or something?
Henry
Well, there is XML behind it, but you don't need to do anything to turn it on. Whatever the "cachename" ends up being -- whether you specify it in the component attribute or it derives it from the entity name -- CF will create a new cache region in that XML file for you.
marc esher