3 Replies Latest reply on Oct 15, 2006 10:12 AM by laszlo.fogas

    can't evict manually entity bean from treecache

    laszlo.fogas

      Hi,

      Jboss cache(1.4 sp1) as hibernate 2nd level cache. The cache works fine except I can't evict manually an entity bean from the treecache. Here is the situation:

      First, i obtain a TreecacheMBean instance:

      MBeanServer server = MBeanServerLocator.locate();
      TreeCacheMBean cache;
      try {
      ...
      } catch (Exception e) {
      throw new TechnicalException("hiba", e);
      }


        • 1. Re: can't evict manually entity bean from treecache
          laszlo.fogas

          ehh submit :)

          so, after i checked that my entity bean is in the cache:

          log.info(cache.printDetails());


          and yes it's in the cache

          /a

          /b

          /business

          /model

          /Felhasznalok

          /a.b.business.model.Felhasznalok#1
          item: CacheEntry(a.b.business.model.Felhasznalok)[...]



          after trying to remove it from the cache:

          cache.remove("/a/b/business/model/Felhasznalok/a.b.business.model.Felhasznalok#1");


          but the log says that

          processRemoveNodes(): Can't find node associated with fqn: /a/b/business/model/Felhasznalok/a.b.business.model.Felhasznalok#1Could have been evicted earlier. Will just continue


          I don't understand why!

          if i remove its parent node than works fine, but it would remove all of the objects instance in the cache, and i don't want this behaviour.

          If i put into the cache an object with the same name, it removes that instance using the former mentioned solution.

          Other thing i tried that removing with hibernate:

          session.getSessionFactory().evict(Felhasznalok.class,instance);

          it has no effect.

          Am I doing something wrong?

          thanks in advance, lazlo

          • 2. Re: can't evict manually entity bean from treecache
            brian.stansberry

            Opening caveat: trying to manually manage the Hibernate 2nd level cache sounds like asking for problems.

            The session.evict() call in Hibernate works on the session cache, not the 2nd level cache; that's why it has no effect. Check the Hibernate docs to see if there is an equivalent operation user's are meant to perform on the 2nd level cache; if so use that instead of manipulating TreeCache directly.

            If you decide you still want to manipulate the tree cache directly, do you want to call evict() or remove()?

            The log message you quoted is debug logging from the background eviction process that you're manually overriding; why are you concerned about it? It's not telling you that your remove() call didn't work.

            • 3. Re: can't evict manually entity bean from treecache
              laszlo.fogas

              sorry, everything works with the sessionFactory.evict() method. (the factory's evict is operates on the 2nd level cache)

              thanks, lazlo