Geeks With Blogs
Mike Nichols - SonOfNun Technology If I were the captain on a big steamboat...

When trying to map a custom type using NHibernate, you have to decide whether to implement IUserType or ICompositeUserType. IUserType is slightly simpler to implement but doesn't support using HQL for the custom types underlying properties. To use the power of HQL, you'll need to implement ICompositeUserType. I have an generic example here. Using this interface you can use the underlying properties within your custom type in the HQL ... very cool.

The greates benefit of using these interfaces in lieu of writing code within the classes themselves to do some kind of transform into the custom type is Separation of Concerns...the Domain shouldn't be required to perform ad hoc methods to accomodate an OR/M's limitations. Fortunately, NHibernate rocks and provides tons of hooks to support the domain!

References

  • Hibernate in Action (Bauer,King) ~ pp. 202-208
Posted on Monday, August 14, 2006 5:09 AM O/R Mappers | Back to top


Comments on this post: NHibernate Custom Type Mapping : ICompositeUserType versus IUserType

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Mike Nichols | Powered by: GeeksWithBlogs.net