Hibernate version: NHibernate 1.2.0 beta
I want to use a custom type for some of the id-fields of my entities.
for example, i'd like to make a CustomerId-type, so that there won't be confusion about its type... is it long int or whatever?
but i'm not sure how to do the mapping.
I guess that type would be something like:
Code:
struct CustomerId
{
private int m_Value;
internal int Value {get{...}set{...}}
// probably will need to do some implementation of hashcode/equals/...
}
Only nhibernate should know about Value's type, and should map it to a single column in the database (in this case it would be the primary key column, autonum of int), my client-code would just use a CustomerId-instance.
I think it must be possible by creating a CustomerIdUserType that implements IUserType, but i haven't been successfull in implementing it yet.
Or should i derive my type from ValueType?
Anyone that has done something similar before and could post an example of the type and the mapping? or is this just complete non-sense and a very stupid idea for this or that good reason?
Thanks in advance,
greetz sotto