From: Gavin_King/Cirrus%<CI...@ci...> - 2002-08-06 01:59:13
|
>I would expect the following to happen: <snip> yep, thats right. The problem is that Hibernate models a collection as a seperate object from the entities contained in the collection. Thats why we (inefficiently) require two selects to materialize an association 1. To load the collection with ids + indices 2. To select all the referenced entities At some stage we need to rework this because of the inefficiency involved. But remember that not all Hibernate collections contain entities so this is a bit more work than it sounds (collections of values are retrieved in exactly one select). So essentially the collection cache (on CollectionPersister) caches the results of part 1. The entity cache (on ClassPersister) caches the results of part 2. (Just in case its been non-obvious from previous discussions, each entity class has its own ClassPersister + hence its own cache. Likewise each collection role has its own CollectionPersister + cache.) Anyway, I had spent so much time talking + thinking about all this that I knew exactly what to do to implement this (the collection cache) and so I just went ahead and did it last night. It only took me a couple of hours but would have taken someone else much longer. I've just got the configuration side left to worry about.... Gavin. |
From: Gavin_King/Cirrus%<CI...@ci...> - 2002-08-06 12:49:36
|
> Great! Let me know when it's ready, I'm looking forward to trying it out. do a cvs upd now..... |
From: Gavin_King/Cirrus%<CI...@ci...> - 2002-08-09 02:42:53
|
>And I would expect 3 SQL statements with all the many-to-ones and >collections should get resolved from the cache. To enable caching, you need to add <jcs-cache usage="read-write"/> to all <class>, <set>, <map>, <list>, <array>, <primitive-array> elements that you want to cache. :) >My first shot at this returned: > >cirrus.hibernate.HibernateException: You tried to persist an object with a >reference to a transient instance - save the transient instance first This usually means you have an object sitting in the session with a reference to a transient object, at a point when the session was flushed. (ie. you saved a parent but not its child or you loaded an object and then assigned a reference to a child you hadn't saved yet.) If this exception occurred in any other circumstance, it would be a bug and I would *need* to know about it. But I doubt that.... |
From: Gavin_King/Cirrus%<CI...@ci...> - 2002-08-09 14:04:55
|
>you can of course use usage='read-only' isnt it ? yes, if appropriate. >I am wondering something here: > >If we got this simple one to many: > >i have declarated the class bar and the class foo to use jcs-cache, shoudnt >the collection of bar in the class foo cached automatically ? No. >If i have to specify that the collection need to be cached, will it use the >same JCS region as the com.illflow.Bar ? No. we can discuss this; to me its an implementation detail + the current behaviour was the simplest solution. |
From: Christian M. <vc...@cl...> - 2002-08-09 14:35:26
|
----- Original Message ----- From: <Gavin_King/Cirrus%CI...@ci...> To: "Christian Meunier" <vc...@cl...> Cc: "Urberg, John" <ju...@ve...>; <hib...@li...> Sent: Friday, August 09, 2002 3:48 PM Subject: Re: FW: [Hibernate-devel] Getting Collections to pull data from the cache > > >you can of course use usage='read-only' isnt it ? > > yes, if appropriate. Good hehe i am not a big fan of read-write cache in clustered env ;) > > >I am wondering something here: > > > >If we got this simple one to many: > > > >i have declarated the class bar and the class foo to use jcs-cache, > shoudnt > >the collection of bar in the class foo cached automatically ? > > No. That is not a big issue, it's something that could be enhanced later i guess > > >If i have to specify that the collection need to be cached, will it use > the > >same JCS region as the com.illflow.Bar ? > > No. Here i dont understand ( beside the fact that there is a technical issue i dont figure out ) , why i would want to get 2 JCS cache region for the exactly same class of objects ? Peace Christian Meunier |
From: Gavin_King/Cirrus%<CI...@ci...> - 2002-08-09 15:04:03
|
>It comes from your auxiliary DC (Disk Cache ) cache. >My guess is that the path you gave to store objects on the disk is not >correct or it's a file permission issue. oh yeah. stupid. I didn't notice the SEVERE. yeah, ummm ... what he said... just try disabling the auxiliary cache for a start.... >Here i dont understand ( beside the fact that there is a technical issue i >dont figure out ) , why i would want to get 2 JCS cache region for the >exactly same class of objects ? well, for a start we have toplevel collections which don't actually belong to any class.... a particular *instance* might belong to an instance of a particular class but in general the toplevel collection role doesn't belong to a class. So if we want to keep all instances of a collection role in the same region (a good thing), the role needs its own region. I mean, we can write some special code for special cases (nested collections), but I'm not sure its worth the effort. Its not like the application should be looking at or caring about the layout of the JCS regions. |
From: Christian M. <vc...@cl...> - 2002-08-09 16:35:00
|
> >Here i dont understand ( beside the fact that there is a technical issue i > >dont figure out ) , why i would want to get 2 JCS cache region for the > >exactly same class of objects ? > > well, for a start we have toplevel collections which don't actually belong > to any class.... a particular *instance* might belong to an instance of a > particular class but in general the toplevel collection role doesn't belong > to a class. So if we want to keep all instances of a collection role in the > same region (a good thing), the role needs its own region. I see, however ideally i believe collections that represent one-to-many associations should not have their own region. Again it's some optimization and it's not urgent at all Thanks for your comments gavin Regards Christian Meunier |