Yes, you're right - I'm an idiot :)
However with the BIGINT, I'm still getting an exception, although different:
System.ArgumentException: No mapping exists from DbType UInt32 to a known
SqlDbType.
Not sure if it's the late hour, me being an idiot again, or it just
won't work this way.
Fabio Maulo wrote:
What ?
Follow the xsd and re-read what I wrote....
<property .......>
<column name="xxxx" sql-type="whatever"/>
</property>
2009/10/7 Krzysztof Koźmic <[email protected]
<mailto:[email protected]>>
Yeah, IUserType is what I ended up doing, but I consider this
behavior a bug anyway.
Fabio... I get mapping exception (on the trunk)
"XML validation error: The 'sql-type' attribute is not declared."
Ayende Rahien wrote:
I don't think so, at the time we create the adapters, we don't
know what the value in the DB will be.
This isn't actually a problem, however.
NHibernate may be somewhat lax about these things, but the proper
way to support such a scenario is to provide value conversion
using an IUserType
2009/10/7 Krzysztof Koźmic <[email protected]
<mailto:[email protected]>>
I was trying to create a patch for scenarios where we have
one numeric type of property on the model, and we map it to
different type in DB, which currently produces exception in
NHibernate.
In my scenario, where I stumbled upon this bug I had uint on
my model, that I wanted to map to long on a SQL Server
database (which apparently does not support unsigned types,
which is besides the point).
So with Entity like this:
public class UIntAsLong
{
private Guid Id { get; set; }
public virtual uint UIntProp { get; set; }
}
and mapping like this:
<?xml version="1.0"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Foo"
namespace="Foo">
<class name="UIntAsLong">
<id name="Id"/>
<property name="UIntProp" not-null="true" type="long"/>
</class>
</hibernate-mapping>
I'm trying to make it work.
The reason for the exception, is that NHibernate is basically
trying to do the following:
uint foo = 123u;
long fooLong = foo; //implicit cast
object fooObj = fooLong; //boxing
foo = (uint)fooObj; //trying to do unboxing and numeric
conversion at onece - runtime exception.
For this to work, instead of the last line we'd have to have:
long fooLongAgain = (long)fooLong; //unboxing
uint fooUint = (uint)fooLongAgain; //numeric conversion
This seemed like a trivial change, but there's *one piece of
information missing* - the ReflectionOptimizer class, which
generates the getters and setters does not know to what type
the property is being cast (the long in the above example).
Is there a way to provide it with that information?
Krzysztof
--
Fabio Maulo