Effect of Enabled Hibernate Level 2 cache on Domain

23 views
Skip to first unread message

Yagnesh Chawda

unread,
Mar 28, 2011, 2:42:34 AM3/28/11
to Indian Groovy & Grails User Group
Does any one has idea about this thread that I have created at Gails
mailing-list ? :
http://grails.1312388.n4.nabble.com/Effect-of-Enabled-Hibernate-Level-2-cache-on-Domain-td3405253.html

Hi,
If I enable Hibernate Second Level Cache for my app. And put proper
eh-cache.xml. Lets say I have 3 domain classes.

1. Brand
2. User
3. BrandUserRole

class Brand {
....

static hasMany = [ brandUserRoles: BrandUserRole]

static mapping = { cache true }
...
}

class User {
.....

static hasMany = [ brandUserRoles:BrandUserRole]

.....
}

class BrandUserRole {
....

static belongsTo = [brand: Brand, user: User]
....
}

As you can see, only Brand has mapping for "cache true". Following
are my doubts (Sorry for so many ):


1. Does that mean that User and BrandUserRole and User will Never get
cached ?
2. Will dynamic methods like findAll etc. on Brand will automatically
start caching the results or I need to tell in the call to make that
as cacheable query ?
3. If Author and BrandUserRoles are still cacheable because of default
in datasource.groovy, I assume we have to set "cache false" explicitly
if I dont want to cache some domain as its getting updated too
frequently and it makes no sense to cache it.

Actually I am gonna try out with some sample code soon, but would be
great if I can get some rough idea before hand in the mean time. I
will surely update my blog http://yagneshchawda.blogspot.com/ when I
am done with my testing on this

Actually ther are few more question related to this, but it all
depends what answers I find for above questions

Venkatesh S

unread,
Mar 28, 2011, 2:47:16 AM3/28/11
to ig...@googlegroups.com
Hi Yagnesh,

I suggest you to install http://grails.org/plugin/grails-melody and do a simple monitoring. This will answer all your questions.

Thanks
Venki

Yagnesh Chawda

unread,
Mar 29, 2011, 12:30:20 PM3/29/11
to Indian Groovy & Grails User Group
Hey,
Thanks a lot Venki. Its really fantastic tool.
Also I have shared some of my findings on my blog here :
http://yagneshchawda.blogspot.com/2011/03/understandings-grails-gorm-secondary.html

On Mar 28, 11:47 am, Venkatesh S <mailvenkate...@gmail.com> wrote:
> Hi Yagnesh,
>
> I suggest you to installhttp://grails.org/plugin/grails-melodyand do a
> simple monitoring. This will answer all your questions.
>
> Thanks
> Venki
>
> On Mon, Mar 28, 2011 at 12:12 PM, Yagnesh Chawda
> <yagnesh.cha...@gmail.com>wrote:
>
> > Does any one has idea about this thread that I have created at Gails
> > mailing-list ? :
>
> >http://grails.1312388.n4.nabble.com/Effect-of-Enabled-Hibernate-Level...
> > will surely update my bloghttp://yagneshchawda.blogspot.com/when I
Reply all
Reply to author
Forward
0 new messages