-->
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.  [ 1 post ] 
Author Message
 Post subject: can't sort out this type mismatch
PostPosted: Thu Jul 31, 2008 4:33 pm 
Newbie

Joined: Thu Jul 31, 2008 4:17 pm
Posts: 5
NHibernate version: NHibernate-1.2.1

The persisted classes:
The queried class
Code:
public class CollectionEntry
{
    private Int32 id;
    private DateTime created;
    private CollectionGeo geoLoc;

    public CollectionEntry(){}

    public virtual Int32 Id
    {
        get { return id; }
        set { id = value; }
    }

    public virtual DateTime Created
    {
        get { return created; }
        set { created = value; }
    }

    public virtual CollectionGeo GeoLoc
    {
        get { return geoLoc; }
        set { geoLoc = value; }
    }
}


.. contains a geoLoc ..

The abstract base class for geoLoc
Code:
public abstract class CollectionGeo
{
    private Int64 id;
    public override abstract String ToString();

    public virtual Int64 Id
    {
        get { return id; }
        set { id = value; }
    }
}


Subclass for geoLoc

Code:
public class PointGeo : CollectionGeo
{
    private Double lat;
    private Double lon;

    public PointGeo() { }

    public virtual Double Lat
    {
        get { return lat; }
        set { lat = value; }
    }

    public virtual Double Lon
    {
        get { return lon; }
        set { lon = value; }
    }
}


Mapping documents:
For the main item
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="DataAccessManager" namespace="DataAccessManager.Collections">
  <class name="CollectionEntry" table="collectionentry">
    <id name="Id">
      <column name="id" sql-type="int" length="11" not-null="true"/>
      <generator class="assigned"/>
    </id>
    <property name="Created" column="created" sql-type="datetime"/>
    <one-to-one name="GeoLoc" class="CollectionGeo" cascade="all-delete-orphan" fetch="join"/>
  </class>
</hibernate-mapping>


For the contained geoLoc object
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="DataAccessManager" namespace="DataAccessManager.Collections">
  <class name="CollectionGeo" table="collectiongeo">
    <id name="Id">
      <column name="id" sql-type="bigint" length="20" not-null="true"/>
      <generator class="assigned"/>
    </id>
    <joined-subclass name="PointGeo" table="pointgeo">
      <key column="id" foreign-key="CollectionGeo.id"/>
      <property name="Lat" column="lat"/>
      <property name="Lon" column="lon"/>
    </joined-subclass>
  </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Code:
ITransaction tx = sess.BeginTransaction();

IQuery q = sess.CreateQuery("from CollectionEntry colEnt order by colEnt.Created desc");

IList<CollectionEntry> resultSet = q.List<CollectionEntry>(); // fails here


Full stack trace of any exception that occurs:

Code:
NHibernate.ADOException was unhandled
  Message="could not execute query\r\n[ select collection0_.id as id3_, collection0_.tailNumber as tailNumber3_, collection0_.requestingUser as requesti3_3_, collection0_.created as created3_, collection0_.filled as filled3_, collection0_.lastModified as lastModi6_3_, collection0_.status as status3_, collection0_.synced as synced3_, collection0_.type as type3_, collection0_.approved as approved3_, collection0_.start as start3_, collection0_.latest as latest3_, collection0_.res as res3_, collection0_.scan_duration as scan14_3_, collection0_.revisit_rate as revisit15_3_, collection0_.eoir_height as eoir16_3_, collection0_.eoir_width as eoir17_3_, collection0_.eoir_prod_id as eoir18_3_, collection0_.radar_prod_id as radar19_3_, collection0_.radar_priority as radar20_3_, collection0_.radar_alt as radar21_3_, collection0_.radar_coll_az as radar22_3_, collection0_.radar_latest_start as radar23_3_ from collectionentry collection0_ order by  collection0_.created desc ]\r\n[SQL: select collection0_.id as id3_, collection0_.tailNumber as tailNumber3_, collection0_.requestingUser as requesti3_3_, collection0_.created as created3_, collection0_.filled as filled3_, collection0_.lastModified as lastModi6_3_, collection0_.status as status3_, collection0_.synced as synced3_, collection0_.type as type3_, collection0_.approved as approved3_, collection0_.start as start3_, collection0_.latest as latest3_, collection0_.res as res3_, collection0_.scan_duration as scan14_3_, collection0_.revisit_rate as revisit15_3_, collection0_.eoir_height as eoir16_3_, collection0_.eoir_width as eoir17_3_, collection0_.eoir_prod_id as eoir18_3_, collection0_.radar_prod_id as radar19_3_, collection0_.radar_priority as radar20_3_, collection0_.radar_alt as radar21_3_, collection0_.radar_coll_az as radar22_3_, collection0_.radar_latest_start as radar23_3_ from collectionentry collection0_ order by  collection0_.created desc]"
  Source="NHibernate"
  StackTrace:
       at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
       at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters)
       at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes)
       at NHibernate.Hql.Classic.QueryTranslator.List(ISessionImplementor session, QueryParameters queryParameters)
       at NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters, IList results)
       at NHibernate.Impl.SessionImpl.Find[T](String query, QueryParameters parameters)
       at NHibernate.Impl.QueryImpl.List[T]()
       at RAISR_FV_GUI.OverlayManagerForm..ctor() in C:\Documents and Settings\PrestJo1\Desktop\Software_0.2\RAISR_FV_GUI\OverlayManagerForm.cs:line 40
       at RAISR_FV_GUI.Program.Main() in C:\Documents and Settings\PrestJo1\Desktop\Software_0.2\RAISR_FV_GUI\Program.cs:line 17
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()


The inner exception message:
Code:
"identifier type mismatch\r\nParameter name: id"


Name and version of the database you are using:
MySQL 5

The generated SQL (show_sql=true):

I set show_sql = true in my hibernate config, but I'm not getting any output to the "immediate" window while in debug mode in Visual Studio 2005.

Debug level Hibernate log excerpt:
Log4Net not yet installed and setup


Comments
First thing to note is that the SQL tables were all setup using Java (w/ annotations) and Hibernate. I'm developing a separate app in C# that needs to make use of the same data and objects.

I've narrowed the problem on my end to the CollectionGeo class. A description of the tables in question shows the id field as bigint(20). I have found that the code will compile if I change CollectionGeo.id to Int32 instead of Int64 -- even if I leave sql-type="bigint" length="20" in the mapping. But truthfully it doesn't seem like much of a fix at all. The original java code indicates a long, not a regular int. We also use the exact same long and Int64 for the id field in another class.

So is there something weird going on here because of the inheritance? What did I screw up? :-\


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

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.