|
I'm having issues getting a many-to-one relationship to work. I have an Application guid stored as a string in two tables. The ApplicationGUID is not required on either side of the relationship. Whenever NHibernate tries to create the object below it says it can't convert the "GUID VALUE" to column of data type int.
Any Ideas?
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Systact.SystactWeb.Entities.Application, Systact.SystactWeb.Entities" table="WA_Applications">
<id name="ID" column="ID" type="Int32" length="4" unsaved-value="0">
<generator class="identity" />
</id>
<bag name="AppLogEntries">
<key column="ApplicationGUID" />
<one-to-many class="Systact.SystactWeb.Entities.AppLogEntry, Systact.SystactWeb.Entities" />
</bag>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Systact.SystactWeb.Entities.AppLogEntry, Systact.SystactWeb.Entities" table="WA_AppLogEntries">
<id name="ID" column="ID" type="Int32" length="4" unsaved-value="0">
<generator class="identity" />
</id>
<many-to-one name="Application" class="Systact.SystactWeb.Entities.Application, Systact.SystactWeb.Entities" column="ApplicationGUID" />
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
[SqlException (0x80131904): Syntax error converting the varchar value '2296057c-78de-4d97-a8af-2ab153f48f3e' to a column of data type int.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857306
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734918
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
System.Data.SqlClient.SqlDataReader.HasMoreRows() +150
System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout) +214
System.Data.SqlClient.SqlDataReader.Read() +9
NHibernate.Driver.NHybridDataReader.Read() +14
NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies) +493
NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies) +65
NHibernate.Loader.OneToManyLoader.Initialize(Object id, ISessionImplementor session) +117
NHibernate.Collection.AbstractCollectionPersister.Initialize(Object key, ISessionImplementor session) +45
Name and version of the database you are using:
SQL Server 2000
|