-->
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: [ACCESS] Invalid cast exception
PostPosted: Fri Dec 02, 2005 7:26 pm 
Good evening to everyone :)
I recently upgraded NHibernate from 0.99.2.0 to 1.0.1.0 and JetDriver from a version downloaded about a month ago from here
http://jira.nhibernate.org/browse/NH-437
to the one contained on NHibernate-Contrib 1.0.1 (maybe it's the same release, but i'm not sure).

I'm working on a MSAccess-based application that, until this upgrade, was working fine. What i'm experiencing is that, everytime I try to persist a new class that has a Increment ID, I get an invalid cast exception. I tried it with a very simple example like this
Class:
Code:
public class SimpleItem
   {
      public SimpleItem()
      {
      }
      #region Private members
      private int id;
      private string description;
      #endregion
      #region Public props
      public int ID
      {
         get{return id;}
         set
         {
            if (value != id)
            {
               id = value;
            }
         }
      }
      public string Description
      {
         get{return description;}
         set
         {
            if (value != description)
            {
               description = value;
            }
         }
      }

with this mapping
Code:
<class name="SimpleItem" table="Test">
   <id name="ID" column="ID" type="Int32">
      <generator class="increment" />
   </id>
   <property name="Description" column="Description" />
</class>

The DB Field is a long integer data type.
What I exactly get is a NHibernate.ADOException, with the following stack trace:
Quote:
NHibernate.ADOException: Could not save object ---> System.InvalidCastException: Cast specificato non valido.
at System.Data.OleDb.OleDbDataReader.GetInt64(Int32 ordinal)
at NHibernate.Id.IncrementGenerator.getNext(ISessionImplementor session)
at NHibernate.Id.IncrementGenerator.Generate(ISessionImplementor session, Object obj)
at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything)


I've highlighted the thing that makes me suspicious that something strange is going on with Int64 type (but I'm not using it anywhere!!)

What can I do? has someone experienced the same behaviour?

Thanks in advance!!


Top
  
 
 Post subject: Re: [ACCESS] Invalid cast exception
PostPosted: Fri Dec 02, 2005 7:47 pm 
Sorry, for replying to myself, I've not registered yet to this forum so I cannot edit my previous post.
In NH 1.0.1 release notes, I've found that bugfix that seems to be related to my issue.
[NH-463] - IncrementGenerator returns Int64 but uses an Int32 internally

Just in case it can help... :)


Top
  
 
 Post subject:
PostPosted: Sat Dec 03, 2005 12:43 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes, this was reported some time ago, will be fixed in 1.0.2.


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.