Hello,
I am interested in this thread and would like to offer the following
description of how I am using Guid with Oracle 10g, .Net 2.0,
NHibernate 1.2.1 GA in case it helps you.
I have a RAW(32) column mapped using type="Byte[]" length="32". I
have been told I could be using type="Byte[]" length="16", RAW(16)
instead, but length 32 is working for me and I have not had time to
try length 16 yet. I have tested this on Oracle 10g on 32 and 64 bit
windows servers and Oracle 10g on Linux (CentOS 4.4 32 bit).
I often need the byte array as a string so I use
System.Runtime.Remoting.Metadata.W3cXsd2001 to do the conversions in
C#. (I have not tried using Oracle's HEXTORAW and RAWTOHEX.)
In C# I have:
// to convert byte array to string using .Net native methods of
SoapHexBinary class
using System.Runtime.Remoting.Metadata.W3cXsd2001;
private byte[] _guid = null;
private string _guidString = String.Empty;
public byte[] GUID
{
get
{
if (_guid == null)
{
_guid = Guid.NewGuid().ToByteArray();
}
return _guid;
}
set { _guid = value; }
}
public string GUIDString
{
get
{
if (String.IsNullOrEmpty(_guidString))
{
_guidString = new SoapHexBinary(_guid).ToString();
}
return _guidString;
}
}
To convert from string to byte array I use
SoapHexBinary.Parse(_guidString).Value;
I must point out I am not using _guid as primary key. If you use _guid
as primary key I think you will need to override Equals and implement
a way to compare byte[] arrays, perhaps by converting to string first.
I always generate the GUID in the C# application because the
implementation of Oracle's SYS_GUID on 10g on some AIX and Linux
systems does not work as expected - it returns a constant! See
http://feuerthoughts.blogspot.com/2006/02/watch-out-for-sequential-oracle-guids.html.
Hope this helps.
Michael Hanney.
> This seems to be what I search, so can you post your solution?
>
> Thanks,
> Adrian.
>