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: Many-To-One and One-To-Many issue
PostPosted: Wed Mar 07, 2007 7:23 pm 
Newbie

Joined: Wed Mar 07, 2007 7:11 pm
Posts: 1
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


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.