title: Fluent NHibernate : How can i use Int64 as ID?
body: <p>I'm quite new to the whole concept of ORM, NHibernate and FluentNH, and i'm trying to accomplish something that seems so simple...</p>
  
  <p>I'm trying to retrieve an object that has a field defined as Int64 in it's class. This field would be the ID, as defined in the Map file.</p>
  
  <p>When trying to retrieve a record from the DB, NHibernate returns the following error message :  <em>"Provided id of the wrong type. Expected: System.Int32, got System.Int64"</em></p>
  
  <p>I have a very simple object :</p>
  
  <pre><code>public class Holiday
  {
      public virtual Int64 HolidayID { get; set; }
      public virtual string Name { get; set; }
      public virtual int Day { get; set; }
      public virtual int Month { get; set; }
      public virtual bool IsActive { get; set; }
      public virtual HolidayGroup Group { get; set; }
  
      public Holiday() { }
  
  }
  </code></pre>
  
  <p>the Mapping file (for FluentNH) is the following :</p>
  
  <pre><code>public class HolidayMap : ClassMap&lt;Holiday&gt;
  {
      public HolidayMap()
      {
  
          Id(x =&gt; x.HolidayID);
          Map(x =&gt; x.Name);
          Map(x =&gt; x.Day);
          Map(x =&gt; x.Month);
          Map(x =&gt; x.IsActive);
          HasOne(x =&gt; x.Group);
      }
  }
  </code></pre>
  
  <p>the table structure (generated by NH) is the following:</p>
  
  <pre><code>CREATE TABLE [dbo].[Holiday](
   [HolidayID] [bigint] IDENTITY(1,1) NOT NULL,
   [Name] [nvarchar](255) NULL,
   [Day] [int] NULL,
   [Month] [int] NULL,
   [IsActive] [bit] NULL,
   [HolidayGroup_id] [int] NULL,
  PRIMARY KEY CLUSTERED 
  (
   [HolidayID] ASC
  )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, 
  ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
  ) ON [PRIMARY]
  </code></pre>
  
  <p>and finally, i am trying to retrieve the Holiday instance using this:</p>
  
  <pre><code>    public static Holiday Get(Int64 _holidayID)
      {
          Holiday _holiday = new Holiday();
  
          try
          {
              using (var session = Global.NHibernate_SessionFactory.OpenSession())
              {
                  _holiday = session.Get&lt;Holiday&gt;(_holidayID); // EXCEPTION OCCURS HERE
              }
          }
          catch (Exception _ex)
          {
              // TODO : Implement proper logging
          }
  
          return _holiday;
      }
  </code></pre>
  
  <p>What am i doing wrong??  What's missing?  When deleting the table and redefining my object using an Int32 for the ID, everything works!  I need use a bigger type! </p>
  
  <p>Many thanks!</p>
  
  <p><strong>EDIT 1 :</strong> As <strong>Aaronaught</strong> mentions, i agree, my need for an Int64 is a bit of overhead for storing holidays...  But for a second, let's forget the "Holidays" concept.  What am i going to do with my logging table (5 to 10 events (rows) per seconds!).  Thanks!</p>
  
  <p><strong>EDIT 2 :</strong> @Paco : I'm using NHibernate 2.1.2.4000 and FluentNH 1.0.0.614</p>
  
  <p><strong>EDIT 3 :</strong> After rerading <strong>Daniel Schilling</strong>'s solution, rebuilt a (brand new) simple Holiday object that used an Int64 as an ID.  I was able to retrieve a record from the DB successfully.  As soon as <strong>i added a relationship</strong> to a Group object, when instanciating a Holiday object i received the same error message as earlier...  Here is the HolidayGroup class and mapping, in case you can tell me what i did wrong...</p>
  
  <pre><code>public class HolidayGroup
  {
      public virtual int HolidayGroupID { get; set;}
      public virtual string Name { get; set; }
      public virtual string Notes { get; set; }
      public virtual bool IsActive { get; set; }
      public virtual IList&lt;Holiday&gt; Holidays { get; set; }
  
      public HolidayGroup()
      {
          Holidays = new List&lt;Holiday&gt;();
      }
  }
  </code></pre>
  
  <p>public HolidayGroupMap()
   {
    Id(x => x.HolidayGroupID);
    Map(x => x.Name);
    Map(x => x.Notes);
    Map(x => x.IsActive);
    HasMany(x => x.Holidays)
     .Cascade.All()
   }</p>