Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 4.2.0.GA_CP09, 4.3.0.GA_CP08
    • Fix Version/s: 4.3.0.GA_CP10
    • Component/s: Hibernate
    • Labels:
      None
    • Affects:
      Release Notes
    • Workaround:
      Workaround Exists
    • Workaround Description:
      Hide

      refresh is generally used for generated properties.
      refresh is not required when @Generated annotation is used.
      I did a test with @Generated (so removing .refresh call) and it works.

      Second workaround: manually evicting the new cache entry.

      Show
      refresh is generally used for generated properties. refresh is not required when @Generated annotation is used. I did a test with @Generated (so removing .refresh call) and it works. Second workaround: manually evicting the new cache entry.
    • Release Notes Text:
      Hide
      When a <methodname>refresh()</methodname> method is invoked immediately prior to an <methodname>insert()</methodname>, and second-level caching is enabled, the entity is inserted into the second-level cache. If the <methodname>refresh()</methodname> does not commit successfully, however, the cached data will not be automatically evicted. This occurs because <methodname>refresh()</methodname> does not track entity state. The fix ensures <methodname>refresh()</methodname> tracks entity state at all times.
      Show
      When a <methodname>refresh()</methodname> method is invoked immediately prior to an <methodname>insert()</methodname>, and second-level caching is enabled, the entity is inserted into the second-level cache. If the <methodname>refresh()</methodname> does not commit successfully, however, the cached data will not be automatically evicted. This occurs because <methodname>refresh()</methodname> does not track entity state. The fix ensures <methodname>refresh()</methodname> tracks entity state at all times.
    • Release Notes Docs Status:
      Documented as Resolved Issue
    • Docs QE Status:
      ON_QA

      Description

      code is as follow

      TransactionManager tm = (TransactionManager) new InitialContext().lookup("java:/TransactionManager");
      tm.begin();
      MyEntity e = new MyEntity();
      em.persist(e);
      em.flush();
      em.refresh(e);
      tm.rollback();

      refresh invocation seems to break cache consistency. If refresh is used just before rollback, there is a cache entry (you can see it thanks to following code)

      tm.begin();
      em.clear();
      Session s = (Session)em.getDelegate();
      SessionFactory sf = s.getSessionFactory();
      Map cacheEntries = sf.getStatistics()
      .getSecondLevelCacheStatistics("test")
      .getEntries();
      tm.commit();

      Test done with a very simple entity + HashTableCacheProvider, so I guess the problem in is core or somewhere 'around' refresh implementation.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                stliu Strong Liu
                Reporter:
                AnthonyHib Anthony Patricio
                Writer:
                Jared Morgan
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: