-->
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.  [ 1 post ] 
Author Message
 Post subject: custom type for id
PostPosted: Wed Nov 08, 2006 4:34 pm 
Newbie

Joined: Tue Oct 10, 2006 4:34 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.