> I propose the following solutions:
>
> 1. I think it's possible to add a manual collection cache entry update
> in the postAction() callback. And it'll probably work.

How would you ensure that the cache is consistent ?

"extra lazy collections" is kinda opposite to what "cached collections" is 
about...

I fail to see the problem...

> 2. This one is much harder to fix. I'm planning to add a special flag
> "onlyCached" to the LoadEvent and add the corresponding functionality to
> the DefaultLoadEventListener. So I'll have something like:
> ========
>       public void initializeFromCache(CollectionPersister persister,
> Serializable disassembled, Object owner)
>       throws HibernateException {
>               Serializable[] array = ( Serializable[] ) disassembled;
>               int size = array.length;
>               Object [] loaded=new Object[size];
>               List notInCache=new ArrayList();
>
>               beforeInitialize( persister, size );
>
>               for ( int i = 0; i < size; i++ ) {
>                       loaded[i]=session.tryToLoadFromCache(array[i], owner);
>                       if (loaded[i]==null)
>                               notInCache.add(array[i]);
>               }
>
>               Iterator entities=getSession().createCriteria(
>                       persister.getElementType().getName())
>                       .add(Restrictions.in("id",notInCache))
>                       .iterate();
>               for(int i=0; i < size; i++)
>               {
>                       if (loaded[i]!=null)
>                               list.add(loaded[i]);
>                       else
>                               list.add(entities.next());
>               }
>       }
> ========

Bulk loading of non-cached elements could be usefull...

> 3. This is a fairly large task, which requires changing some of
> Hibernate fundamentals (like LoadEvent). But I think I can do it.

Have you looked in Hibernate 3.3 and checked if the recent refactorings
that were done here for the cache api is enough for you ?

/max

_______________________________________________
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev

Reply via email to