Hi Roger,

This the the generated hbm:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
access="property" auto-import="true" default-cascade="none" default-
lazy="true">
  <class xmlns="urn:nhibernate-mapping-2.2" mutable="true"
name="NIHR.eSystematics.Core.Domain.ResearchProject,
NIHR.eSystematics.Core, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=0b870c62165de31d" table="`ResearchProject`">
    <id name="Id" type="System.Int32, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="ResearchProjectId" />
      <generator class="identity" />
    </id>
    <bag cascade="all" name="Studies" mutable="true">
      <key>
        <column name="ResearchProjectId" />
      </key>
      <one-to-many class="NIHR.eSystematics.Core.Domain.Study,
NIHR.eSystematics.Core, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=0b870c62165de31d" />
    </bag>
    <property name="Title" type="System.String, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="Title" not-null="true" />
    </property>
    <property name="Method"
type="FluentNHibernate.Mapping.GenericEnumMapper`1[[NIHR.eSystematics.Core.Domain.AssessmentMethod,
NIHR.eSystematics.Core, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=0b870c62165de31d]], FluentNHibernate, Version=1.1.0.0,
Culture=neutral, PublicKeyToken=8aa435e3cb308880">
      <column name="Method" not-null="true" />
    </property>
    <property name="Created" type="System.DateTime, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="Created" not-null="true" />
    </property>
    <property name="CreatedBy" type="System.String, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="CreatedBy" not-null="true" />
    </property>
  </class>
</hibernate-mapping>

Many thanks for your assistance,

Peter

On Jun 22, 4:14 pm, Roger Kratz <[email protected]> wrote:
> I don't know FH well so...
> Can you please export your configuration to hbm format (something like 
> FluentMappings.ExportTo(...))?
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of 
> Pete
> Sent: den 22 juni 2011 12:00
> To: nhusers
> Subject: [nhusers] NHibernate.Envers and Enum Mappings
>
> Hi,
>
> I've just started a project which uses NHibernate, and we also have a need to 
> provide auditing of our entities - I came acrosss Envers, which seems to be a 
> perfect solution to our auditing requirement.
>
> I'm trying to map the following Enum with Fluent NHibernate:
>
> public enum AssessmentMethod
>     {
>         NotSet,
>         VanTulder,
>         ReviewPaper,
>         UserDefined,
>     }
>
> public ResearchProjectMap()
>         {
>             Id(x => x.Id)
>                 .Column("ResearchProjectId")
>                 .GeneratedBy.Identity();
>             HasMany(x => x.Studies).Cascade.All();
>             Map(x => x.Title).Not.Nullable();
>             Map(x => x.Method).Not.Nullable(); //Assessment Method
>             Map(x => x.Created).Not.Nullable();
>             Map(x => x.CreatedBy).Not.Nullable();
>         }
>
> I'm allowing NHibernate to work out the type for AssessmentMethod, which 
> works fine for NHibernate to create the domain tables, however Envers seems 
> to be unable to determine the type for the creation of the audit tables with 
> the following error:
>
> Could not determine type for: enumstring - AssessmentMethod, 
> NHibernate.Envers, for columns: NHibernate.Mapping.Column(Method)
>
> I have managed to get it working by using:
>
> Map(x => x.Method).Not.Nullable().CustomType<AssessmentMethod>();
>
> However, this stores the enum value as an int in the database, where I really 
> want it to be a string, so that Audit data is easier to read.
>
> I must stress that I am pretty new to NHibernate, so I may have made an 
> obvious mistake in the question being asked.
>
> Thank you in advance,
>
> Pete
>
> --
> 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 
> athttp://groups.google.com/group/nhusers?hl=en.- Hide quoted text -
>
> - Show quoted text -

-- 
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