Mapping a primary key of type binary(16)
I have a legacy schema that contains tables with composite keys where some of the keys are of type binary(16) -- its a MD5 hash of the other columns. I am having trouble finding the right way to map this structure. The first thing I tried was to simply use byte[] as my domain type, which NHibernate quickly dismissed since byte[] does not implement Equals (duh!). The next thing I tried was to create a custom user type (i.e., implements IUserType) to wrap the byte[] and provide the requisite Equals implementation but this did not work since there appears that NHibernate (v2.1.2) does not support user types in composite keys. The last thing I tried was to use Guid as my domain type hoping that NHibernate would automagically CAST or CONVERT between my domain type (uniqueidentifier) and my column type (binary(16)); it did not. I am currently looking for a way to force NHibernate to wrap all usages of a column c in a CONVERT(uniqueidentifier, c). Is this possible or is there another way to make this work?
2 Posted by mirapalheta on 07 Jul, 2010 12:18 AM
I saw uses for raw(16) (oracle) for Guid, seems that nhibernate use this for
guid types, but other databases (like sql server) have the uniqueidentifier
type. You told that you tried byte[] with a IUserType, but I didn't told
anything about trying Guid with a IUserType. Just a guess.
Daniel Mirapalheta
2010/7/6 Faron <
***@tenderapp.com<tender%***@tenderapp.com>
>