-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: NH2.0 Trunk Bug?
PostPosted: Sun Mar 23, 2008 11:33 pm 
Beginner
Beginner

Joined: Wed Mar 14, 2007 12:35 pm
Posts: 24
I didn't want to file a jira issue until I was sure this was actually an issue (which I'm pretty sure it is). It seems that update scenarios were failing under all of my persistance unit tests. After debugging, I found the following two issues.

First off, the PersistentObjectException always seemed to be firing. RequestedId has a type of object, but seems to always turn out to be bool. When checking for null, it seemed for some reason that my debugger was skipping over it because the bool was true. For this reason, I added the boolean check and fixed that problem.

Code:
DefaultSaveOrUpdateEventListener.cs - starting line 96
            ISessionFactoryImplementor factory = @event.Session.Factory;

            object requestedId = @event.RequestedId;
            object savedId;               
            if (requestedId == null || (requestedId is bool && (bool)requestedId == true))
            {
               savedId = entityEntry.Id;
            }
            else
            {
               if (!entityEntry.Persister.IdentifierType.IsEqual(requestedId, entityEntry.Id, EntityMode.Poco))
               {
                  throw new PersistentObjectException("object passed to save() was already persistent: " +
                     MessageHelper.InfoString(entityEntry.Persister, requestedId, factory));
               }
               savedId = requestedId;
            }

            if (log.IsDebugEnabled)
            {
               log.Debug("object already associated with session: " +
                  MessageHelper.InfoString(entityEntry.Persister, savedId, factory));
            }

            return savedId;


Problem #2 came shortly after. SaveOrUpdate in cascading scenarios would pass the proxy object to the following method with obj.GetType() obviously failing at GetClassPersister. Thus the following updates were needed.
Code:
SessionImpl.cs
public override IEntityPersister GetEntityPersister(object obj)
      {
            System.Type type = obj.GetType();
            if (obj is INHibernateProxy)
            {
                type = ((INHibernateProxy)obj).HibernateLazyInitializer.PersistentClass;
            }
         return GetClassPersister(type);
      }


I've noticed the updates to the trunk have been very frequent and I wasn't sure if you guys were having these issues? So far, I've found the trunk VERY stable till this issue which was pretty minor to fix. Please let me know if you want this filed under jira.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.