Quantcast

Effect of Enabled Hibernate Level 2 cache on Domain

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Effect of Enabled Hibernate Level 2 cache on Domain

Yagnesh Chawda
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

--
Thanks And Regards,
Yagnesh Chawda.
http://yagneshchawda.blogspot.com
http://twitter.com/yagneshchawda

************************************************
Good planets are hard to find. Print less!
Save energy to keep your future bright !!
************************************************
"Earth provides enough to satisfy every man's need,
but not every man's greed." - Mahatma Gandhi
************************************************
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Effect of Enabled Hibernate Level 2 cache on Domain

Yagnesh Chawda
Hi,
  As promised I have put some of the findings on my blog here: http://yagneshchawda.blogspot.com/2011/03/understandings-grails-gorm-secondary.html
--
Thanks And Regards,
Yagnesh Chawda.
http://yagneshchawda.blogspot.com
http://twitter.com/yagneshchawda

************************************************
Good planets are hard to find. Print less!
Save energy to keep your future bright !!
************************************************
"Earth provides enough to satisfy every man's need,
but not every man's greed." - Mahatma Gandhi
************************************************
Loading...