1 2 Previous Next 18 Replies Latest reply on Mar 8, 2006 4:23 PM by clebert.suconic Go to original post
      • 15. Re: Hibernate Proxy possible fix
        johnv/dpol

        Clebert Suconic wrote:


        John...

        Please, help me understand this issue better.

        You only changed your code, and it worked.

        Can you provide me a testcase the way it was [not] working before?


        Clebert

        • 16. Re: Hibernate Proxy possible fix
          johnv/dpol

          Hi Clebert,

          Sadly enough I don't have time for it.

          I found it really strange as when you load it from the steam it suddenly loads different data then expected.

          It happens when some one makes the standard error in making the link to the referring element too when adding to a set.

          For example a person contains a set of contacts, when a new contact is added to the person like and added to the set of contacts, I mistakenly also set the person in the contact, which is not needed.

          addContact()
          {
          Contact newcontact=new Contact()
          contacts.add(newcontact);
          newcontact.setperson(this);
          }

          Somehow we got also very strange persistence errors like that and i had to call persist before addition and after addition, otherwise hibernate went totally crazy. Having the persist added, hibernate worked. However now in the newer version it broke in deserialization.

          After a lot of looking around I fixed the original back link problem (removed several lines) and all special code was not needed anymore and all works now.

          Maybe the error is related to the forced saves as these happened only on contract party roles.

          In the code that sets the content of a contract

          Contract::SetContent()

          // Session session = HibernateUtil.getSession(); (we store here the injected session, this is a fix to have old code still working )
          // session.persist(this);// need to be saved before the contractpartyrole
          contractpartyrole = new ContractPartyRole(this /*contract*/, contractrole, party, partyrolecontext); //here the links are already set, so setting them again should not be done
          addContractPartyRole(contractpartyrole);
          // session.persist(contractpartyrole);// somehow needs to be saved
          // otherwise it is later updated, while it is not inserted, i think that
          // counts as a bug of hibernate



          public ContractPartyRole::ContractPartyRole(Contract contract2, ContractRole contractRole, ContractParty contractParty, Properties partyrolecontext)
          {
          contract = contract2;
          //contract.AddContractPartyRole(this);//removed as it caused all the trouble
          role = contractRole;
          //role .AddContractPartyRole(this);//removed as it caused all the trouble
          party = contractParty;
          //party.AddContractPartyRole(this);//removed as it caused all the trouble
          if (partyrolecontext != null)
          {
          setProperties(partyrolecontext);
          }
          }

          public void Contract:: addContractPartyRole(ContractPartyRole contractPartyRole)
          {
          getPartyRoles().add(contractPartyRole);
          //back linking removed
          // if (!partyRoles.contains(contractPartyRole))
          // {
          // contractPartyRole.setContract(this);
          // }
          }

          Hope it gives some insight to reproduce this strange test cases. Otherwise it will likely help if someone has similar problems.

          • 17. Re: Hibernate Proxy possible fix
            clebert.suconic

            Just as an information to others:
            This whole thread was just publishing a private thread to the forum (what was great)

            The HibernateProxy serialization was fixed.

            I had three problems there:
            - ClassArrayPersistence
            - ReadResolve not working as expected
            - Creating a constructor for an interface, what was causing the ClassCastException.

            That loop on the first post of yours, is where I'm supposed to look for the ghost constructor. I need to create a constructor with empty arguments, avoiding calling any default constructor you might have in your class. (Weird definition, but this is how it works in Java).

            • 18. Re: Hibernate Proxy possible fix
              clebert.suconic

              I had create extra testcases within JbossSerialization to validate Circular References, and didn't find any problem.

              this was a Hibernate mapping problem, or a serialization?


              It's not clear to me what is the problem.

              1 2 Previous Next