-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem with char(16) charset OCTETS used for GUID(Firebird)
PostPosted: Mon Aug 08, 2005 6:08 am 
Hi,

as long as I was using char(32) with default charset everything was fine, now it says it can't resolve the parameter (System.InvalidCastException) after I changed it to char(16) with charset OCTETS.

My code:

IList repertoires = DatabaseHelper.Session.CreateCriteria(typeof(Repertoire)).Add( Expression.Eq("RepertoireGUID", gidRepertoire)).List();

And my XML file:

<class name="ChessPositionTrainer.BusinessObjects.NHibernate.Repertoire, ChessPositionTrainer" table="Repertoire">
<id name="RepertoireGUID" column="RepertoireGUID" type="Guid">
<generator class="assigned" />
</id>
....

While I can't query anymore using type "GUID" for my column "RepertoireGUID" I can still save new objects so here it seems to have no problem to resolve the datatype.

The code was working as long as I was storing the GUID into a char(32) field.

Do I have to change the type now? If yes, which type?

Thanks for any hint.

Regards,

Stefan


Top
  
 
 Post subject: Additional info
PostPosted: Tue Aug 09, 2005 5:19 am 
If I use the DbCommand object I have no problems to use a GUID as parameter. The following code works:

DatabaseHelper.DbCommand.CommandText = "SELECT COUNT(*) FROM REPERTOIRE WHERE REPERTOIREGUID = @REPERTOIREGUID";
DatabaseHelper.DbCommand.CommandType = System.Data.CommandType.Text;
FbParameter parameter = new FbParameter("@REPERTOIREGUID", FbDbType.Guid);
parameter.Direction = ParameterDirection.Input;
parameter.Value = gidRepertoire;
DatabaseHelper.DbCommand.Parameters.Add(parameter);
return (Convert.ToInt16(DatabaseHelper.DbCommand.ExecuteScalar())>0);

However, doing more or less the same with the NHibernate native method "find" fails. The following code is NOT working:

IList repertoires = DatabaseHelper.Session.Find("FROM Repertoire WHERE RepertoireGUID = ?", gidRepertoire, TypeFactory.GetGuidType());

==> System.InvalidCastException

Source: FirebirdSql.Data.Firebird
at FirebirdSql.Data.Firebird.FbCommand.UpdateParameterValues()
at FirebirdSql.Data.Firebird.FbCommand.ExecuteCommand(CommandBehavior behavior, Boolean returnsSet)
at FirebirdSql.Data.Firebird.FbCommand.ExecuteReader(CommandBehavior behavior)
at FirebirdSql.Data.Firebird.FbCommand.ExecuteReader()
at FirebirdSql.Data.Firebird.FbCommand.System.Data.IDbCommand.ExecuteReader()
...

Like I said, this problem only occurs if I try to use char(16) with charset OCTETS instead of char(36) with default charset as the field to store my GUIDs in Firebird embedded. I would of course prefer the shorter version.

In the XML mapping file I've tried to declare the column RepertoireGUID as type "Guid", "String" and "Char", but without any luck.

Maybe it is a problem of Nhibernate as the firebird OCTETS support is not available for long time? It's still strange that the GUID is correctly converted in "DbCommand", but not in "Find".

Stefan


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.