-->
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.  [ 2 posts ] 
Author Message
 Post subject: Is it possible to map an ID to an unknown type?
PostPosted: Thu Jan 15, 2009 2:49 pm 
Newbie

Joined: Fri Jan 09, 2009 9:13 am
Posts: 4
Hi,

My current project connects to two separate databases almost identical in every respect except for the primary keys. Is it possible to map the ID to some kind of generic type?

Primarily my concern is with mapping the ID to an Int64 or Guid.

Recompiling the project to make the switch is not a problem, I am aware that the mapping file will need to know the correct type, I just want to try and avoid having two separate classes for every table.

Thanks,

Paul


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2009 2:23 pm 
Newbie

Joined: Fri Jan 09, 2009 9:13 am
Posts: 4
In case anyone's interested I've solved (hacked) this by using the object type for all the ID's. NHibernate doesn't actually allow you to map from an Int64 or Guid to an object so I've got round this by not referencing it in the mapping file (not using the name attribute on the Id tag). Then in the DAO I simply call session.GetIdentifier(...) and set it. It's a bit of a hack but as NHibernate uses object to reference Id's anyway one I'm happy to live with.

I'm still interested in a prettier solution if anyone has one.


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

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.