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 at 
http://groups.google.com/group/nhusers?hl=en.

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