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.  [ 4 posts ] 
Author Message
 Post subject: Proxy troubles - no Session (not 'Session was closed')
PostPosted: Wed Dec 06, 2006 12:23 am 
Newbie

Joined: Sun Jul 31, 2005 7:53 pm
Posts: 17
Dear All,

I'm getting errors from my proxy when trying to dereference a one-to-one relationship. I'm stuck because the error is 'no Session', which is quite different from 'Session was closed'.

Looking at the code here...

http://nhibernate.sourceforge.net/clove ... lizer.html

...you only get 'no Session' when no session was given to the proxy constructor, but this is not something I have any control over as far as I'm aware?

Clearly I am forgetting to initialize something or doing something very stupid?

Regards,

Richard.

Hibernate version:
1.2.0 Beta 2

Full stack trace of any exception that occurs:

Code:
NHibernate.LazyInitializationException: Could not initialize proxy - no Session.
   at NHibernate.Proxy.LazyInitializer.Initialize()
   at NHibernate.Proxy.LazyInitializer.GetImplementation()
   at NHibernate.Proxy.CastleLazyInitializer.Intercept(IInvocation invocation, Object[] args)
   at CProxyType... etc.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 06, 2006 6:09 pm 
Newbie

Joined: Sun Jul 31, 2005 7:53 pm
Posts: 17
Apologies, I found the source of the problem: some other part of my code was serializing and deserializing the proxy! Even though the session hadn't been closed, clearly it doesn't survive serialization.

Mind you, this kind of begs the question, why doesn't it throw an error when you try to serialize a proxy?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 3:02 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Why should it? You can reassociate a deserialized proxy with a new session using Lock(..., LockMode.None).


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 10, 2006 7:20 pm 
Newbie

Joined: Sun Jul 31, 2005 7:53 pm
Posts: 17
My apologies - I have not seen LockMode.None before. I'll go and read up on it...


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

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.