4 Replies Latest reply on Dec 18, 2007 2:54 AM by Ganesh Thiagarajan

    Problem with one-to-many assotiations in Hibernate with enab

    Eugene Batogov Newbie

      Hello !
      I have next problem ...
      Link at JIRA:
      http://opensource.atlassian.com/projects/hibernate/browse/HHH-2977

      I have entity MovieCategory and entity Movie.
      MovieCategory relate with Movie in many to one.

      I have two MovieCategories.

      But if I remove Movie from first MovieCategory and add to second MovieCategory,
      then movie have added to second MovieCategory successful.

      But from first MovieCategory this Movie don't remove !!!

      This appear only if JBoss Cache is enabled.
      If second level cache is disabled, then all work properly !

      I am insert part of log, where show how Hibernate work with cache .

      Please, help me! This problem is critical for me !

        • 1. Re: Problem with one-to-many assotiations in Hibernate with
          Brian Stansberry Master

          Please take this up on the hibernate forums until you can establish that your issue is caused by JBoss Cache itself. Hibernate controls what is stored in the 2nd level cache and whether the cached MovieCategory.movies collection gets invalidated out of the cache when you change a Movie. JBC just does what it's told to do by Hibernate.

          Suggestions for getting good free help w/ open source software -- discuss on forums before filing bug reports; don't mark your reports as "Critical" but let the developers make that determination, and don't say stuff like "Please, help me! This problem is critical for me !". Unless of course you want to buy a support contract, in which case you can do all these things and we won't complain at all. ;-)

          • 2. Re: Problem with one-to-many assotiations in Hibernate with
            Eugene Batogov Newbie

            Thanks for quick answer !

            I long explore log of Hibernate and, to my mind, JBoss Cache work properly!
            But !
            Why whereupon without cache all work OK ?

            If take a look at log in JIRA, then JBoss cache FIX CACHE MISS!
            And Hibernate reassign FOREIGN KEY at Movie.
            But cache at Movie Category don't fresh ?!?!

            I don't understand nothing (((

            • 3. Re: Problem with one-to-many assotiations in Hibernate with
              Brian Stansberry Master

               

              If take a look at log in JIRA, then JBoss cache FIX CACHE MISS!


              Not sure what you mean here.


              And Hibernate reassign FOREIGN KEY at Movie.
              But cache at Movie Category don't fresh ?!?!


              JBoss Cache doesn't somehow automatically change what's cached when a Movie's foreign key changes -- it's up to Hibernate's 2nd level cache management code to tell it to do that. That's why I say you need to discuss this on the Hibernate forums -- the Hibernate developers are the ones who understand when they refresh the cache. JBC just stores what it is told to store.

              Imagine Hibernate supported using a java.util.HashMap as a 2nd level cache. If you were having this problem, you wouldn't go to your JRE vendor to find out why the HashMap contents are not what you expect. You'd start by discussing the problem with the Hibernate folks.

              • 4. Re: Problem with one-to-many assotiations in Hibernate with
                Ganesh Thiagarajan Newbie

                may be use lazy="false" in your <Many-to-One > and that should be applicable for child ..