Hibernate version:3.1 
First of all I am sorry if this is the wrong place to post this and I would be happy to post it anywhere I am told to.
Could someone care to explain this code fragment in ForeignKeys.Nullifier?
Code:
if ( object instanceof HibernateProxy ) {
            // if its an uninitialized proxy it can't be transient
            LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
            if ( li.getImplementation(session) == null ) {
               return false;
               // ie. we never have to null out a reference to
               // an uninitialized proxy
            }
            else {
               //unwrap it
               object = li.getImplementation();
            }
         }
The problem is that 
Code:
li.getImplementation(session)
 returns a value 
(and BTW doesn't check whether proxy is not initialized as mentioned in the comments).
But 
Code:
li.getImplementation() 
 throws a ""could not initialize proxy - the owning Session was closed" because the object is transient and its session is closed.
This takes place on session.save(parentObject) which leads to the exception because of the cascading strategy.
thank you