I'm not sure if I'm running into an Nhibernate bug here, or if this
just isn't possible. I seem to be having a problem using a typedef as
a key-property for my entity.

Here are the mappings that fail (only showin relevent sections):

Entity Mapping:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="MyProduct.Core.Domain" assembly="MyProduct.Core" default-
access="property">
    <class name="UserCustomField" table="UserCustomField" lazy="true"
abstract="true">
        <composite-id name="Id" class="UserCustomFieldKey">
            <key-many-to-one name="User" column="UserId" class="User"
access="nosetter.pascalcase-m-underscore" />
            <key-many-to-one name="CustomField" column="CustomFieldId"
class="CustomField" access="nosetter.pascalcase-m-underscore"/>
            <key-property name="EditState" column="EditStateId"
access="nosetter.pascalcase-m-underscore" type="EditState" />
         </composite-id>
    </class>
</hibernate-mapping>

Typedef Mapping:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="MyProduct.Core.Domain" assembly="MyProduct.Core" default-
access="property">
    <typedef name="EditState"
class="MyProduct.Infrastructure.NHibernate.CustomUserTypes.EditStateType,
MyProduct.Infrastructure" />
</hibernate-mapping>


This fails with the following error message:

Executing: TestSetup.RunBeforeAllTests
10:12:12,872 ERROR [TestRunnerThread] ReflectHelper [(null)]- Could
not load type EditState.
System.TypeLoadException: Could not load type EditState. Possible
cause: no assembly name specified.

   at NHibernate.Util.ReflectHelper.TypeFromAssembly
(AssemblyQualifiedTypeName name, Boolean throwOnError)

10:12:13,044 ERROR [TestRunnerThread] Configuration [(null)]- Could
not compile the mapping document:
MyProduct.Infrastructure.UserCustomField.hbm.xml
NHibernate.MappingException: Could not compile the mapping document:
MyProduct.Infrastructure.UserCustomField.hbm.xml --->
NHibernate.MappingException: Could not determine type for: EditState,
for columns: NHibernate.Mapping.Column(EditStateId)


If however, I change my Entity Mapping to inline the type definition
as follows:


            <key-property name="EditState" column="EditStateId"
access="nosetter.pascalcase-m-underscore"
type="MyProduct.Infrastructure.NHibernate.CustomUserTypes.EditStateType,
MyProduct.Infrastructure" />

Everything works fine.

So...am I doing something stupid? Or does Nhibernate just not support
typedefs on key properties? I should note that this typedef works just
fine in other mappings for non-key properties.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.


Reply via email to