-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to get session within IUserType implementation?
PostPosted: Mon Sep 01, 2008 6:20 pm 
Newbie

Joined: Mon Sep 01, 2008 5:07 pm
Posts: 2
Hello.

* I have a class (FooPersister) that implements IUserType to permit instances of another class (Foo) to be persisted as a string.
* Among other things, a Foo instance maintains a reference to a FooParent instance. This reference must be restored when a Foo instance is rehydrated.
* In FooPersister.NullSafeSet, I serialize my Foo instance to a string, which includes the ID of its FooParent.
* In FooPersister.NullSafeGet, I need to use the deserialized ID to get a FooParent instance to assign to the newly hydrated Foo instance. To accomplish this I would like to call session.Get(typeof(FooParent), fooParendId) to get the FooParent, but I don't have a session object.
* I don't want my FooPersister class to be application specific, so I can't have it grab a session that my application is keeping in some well-known place.

Does anyone know how I can obtain the appropriate FooParent instance to assign to my rehydrated Foo instance?

(A related question: I note that ICompositeUserType method signatures provide a session. Why is it included there and not in IUserType?)

I searched the forums and NHibernate source code, including its unit tests, but found no example of this kind of thing.

Thanks for any direction. And thanks for the excellent NHibernate.

Dave


Top
 Profile  
 
 Post subject: Re: How to get session within IUserType implementation?
PostPosted: Sun Sep 21, 2008 4:20 pm 
Newbie

Joined: Mon Sep 01, 2008 5:07 pm
Posts: 2
nhibnewbie wrote:
Does anyone know how I can obtain the appropriate FooParent instance to assign to my rehydrated Foo instance?

(A related question: I note that ICompositeUserType method signatures provide a session. Why is it included there and not in IUserType?)


Well, I'm just getting back to my pet project today. (Darn day job!)

I see 131 views but no replies. Does this mean that IUserType isn't flexible enough to hydrate anything more than a simple type? I'm surprised if that's the case, because NHibernate seems so flexible. Let me know any thoughts, even if they're not definitive. I won't bump this up again.

Dave


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 24, 2008 5:53 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Afaik IUserType is for "simple" types. If you need a more complex type you have to use ICompositeType or IType.

_________________
--Wolfgang


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.