Blog Stats
  • Posts - 62
  • Articles - 1
  • Comments - 56
  • Trackbacks - 40

 

Discriminators in NHIbernate

I had just wrestled with dealing with an NHibernate exception that was beyond useless since I KNEW that my mappings were good . I had used Nhibernates's hbm2ddl tool to generate schema for some tables. The output for one of my tables was as follows:
create table eMerge.dbo.MaterialTest (Id INT IDENTITY NOT NULL, TypeCode NVARCHAR(255) not null, Name NVARCHAR(255) null, Description NVARCHAR(255) null, MaterialTestAgencyId INT null, primary key (Id)) c
If the TypeCode field is used for my discriminator what is the problem wit hthis output? Using NVarchar! THis happened a week ago and then I saw this post on Ayende's blog where he tackled the same thing. He also proposes a best practice to avoid this.
Really, I need to just specify the type in the mapping file to avoid this kind of thing when automating my ddl.
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

No comments posted yet.


Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

 

 

Copyright © Mike Nichols