Yes, the IUserType is the way to go. More than that, it will work...

Few implementation details:
  - IUserType.NullSafeSet: store only the Id of your custom field from
the object passed in
  - IUserType.NullSafeGet: by Id stored previously read your field
from repository/service
  - SQLType - your Id type
  - ReturningType - the type of your custom field.

If you want, you can inject a service/repository in IUserType with an IoC.

Valeriu

On Sat, Oct 24, 2009 at 12:04 AM, Matt Mangold
<[email protected]> wrote:
>
> My domain objects support custom fields that are stored in such a way
> that requires metadata and logic to be applied before their values can
> be stored and retrieved.
>
> I already have a Custom Field Repository that handles the persistence
> of custom fields, and I don't want to try to recreate that logic in
> NHibernate mappings.
>
> I would however like to support lazy loading of my custom fields. It
> would be nice if I could somehow trick the proxy into calling my
> dedicated repository for loading and saving rather than going through
> the NHibernate engine.
>
> One way I solved this problem was to implement an interceptor which
> worked, but I took a performance hit when loading large amounts of
> data, because the dedicated repository was called each time an entity
> was loaded. It would be nice instead, if those calls to load custom
> fields were done lazily! From what I understand lazy loading cannot be
> done in an interceptor.
>
> I have looked into implementing a custom user type (IUserType and
> IUserCollectionType), but the documentation is very limited, and I
> want to learn if it is even possible to do what I want before I go
> down the path of trying.
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to