-->
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.  [ 3 posts ] 
Author Message
 Post subject: Guid Help
PostPosted: Thu Nov 17, 2005 12:28 pm 
I am using Guid's as ID's in my classes/database. How do you tell NHibernate to save the Guid when it is all zeros? The mapping that I am currently using is:
Code:
      <id name="ID" type="Guid" unsaved-value="00000000-0000-0000-0000-000000000000">
         <column name="CustomerID" sql-type="uniqueidentifier" not-null="true" unique="true" index="PK_tblCustomer"/>
         <generator class="native" />
      </id>

I cannot use <generator class="assigned" /> becase there are other systems modifying customer records and the Guid assignment needs to be handled by the database.

The error I get is:
Quote:
Could not create test BE, Exception:NHibernate.Id.IdentifierGenerationException: this id generator generates Int64, Int32, Int16 ---> System.InvalidCastException: Invalid cast from 'System.DBNull' to 'System.Guid'.


Any help/ideas? Thanks in advance.


Top
  
 
 Post subject: Re:
PostPosted: Thu Feb 23, 2006 7:44 am 
Newbie

Joined: Thu Jun 30, 2005 6:36 am
Posts: 4
I have the same problem, do you find the solution??
Thanks !


Top
 Profile  
 
 Post subject: GUID
PostPosted: Fri Feb 24, 2006 12:00 am 
Regular
Regular

Joined: Tue Jan 03, 2006 7:21 am
Posts: 85
using class="native" picks identity, sequence or hilo depending upon the capabilities of the underlying database.

you can use class="guid" and NHibernate will automatically use System.Guid to generate a new guid for you if the instance you are saving has the value of unsaved-value for the Id property.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.