-->
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: ForeignKeys.Nullifier Explanation anyone?
PostPosted: Thu Dec 29, 2005 2:08 pm 
Newbie

Joined: Wed Jun 22, 2005 10:07 am
Posts: 5
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


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.