RE: [nhusers] NHibernate envers not creating tables

718 views
Skip to first unread message

Roger Kratz

unread,
Nov 15, 2012, 4:13:31 AM11/15/12
to nhu...@googlegroups.com

I don’t know fluent nh at all, but it seems you’re updating the schema before configuring envers?

 

From: nhu...@googlegroups.com [mailto:nhu...@googlegroups.com] On Behalf Of Alex Brown
Sent: den 14 november 2012 19:34
To: nhu...@googlegroups.com
Subject: [nhusers] NHibernate envers not creating tables

 

Suddenly, the envers tables (REVINFO etc...) are no longer being created...

 

I setup NHibernate / envers like this:

 

        public static ISessionFactory CreateSessionFactory(FluentConfiguration dbConfiguration = null)

        {

            if (dbConfiguration == null)

                dbConfiguration = Database();

 

            return dbConfiguration

                .Mappings(m => m.FluentMappings.AddFromAssemblyOf<LicenseClassMap>())

                .ExposeConfiguration(cfg => new SchemaUpdate(cfg).Execute(false, true))

                .ExposeConfiguration(SetupEnvers)

                .BuildSessionFactory();

        }

 

        private static void SetupEnvers(Configuration cfg)

        {

            var enversConf = new NHibernate.Envers.Configuration.Fluent.FluentConfiguration();

            enversConf.Audit<License>();

            enversConf.Audit<LicenseActiveFeature>();

 

            cfg.IntegrateWithEnvers(enversConf);

        }

 

I can't tell what's changed to make it stop working...

License and LicenseActiveFeature look like this:

 

My unit tests fail on inserting an entry, because envers is looking for REVINFO.... which hasn't been created?!

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/Zlf8lAsBeskJ.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to
nhusers+u...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.

Roger Kratz

unread,
Nov 15, 2012, 8:08:11 AM11/15/12
to nhu...@googlegroups.com

Good. Thanks.

 

From: nhu...@googlegroups.com [mailto:nhu...@googlegroups.com] On Behalf Of Alex Brown
Sent: den 15 november 2012 12:14
To: nhu...@googlegroups.com
Subject: Re: [nhusers] NHibernate envers not creating tables

 

That's exactly the problem....

Not sure how I managed to get them round the wrong way when i was refactoring.

 

I'm planning to do a blog post shortly on getting this set up with fluent nh today, I'll link from here when it's done to help others

To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/1q_ZH93kp10J.

Meenal Zodage

unread,
Feb 11, 2015, 10:04:14 AM2/11/15
to nhu...@googlegroups.com
Hi Alex,
I am trying to create audit table as follows

_SessionFactory = Fluently.Configure()
                .Database(OracleClientConfiguration.Oracle10
                    .ConnectionString(@"Data Source=ABCD; Persist Security Info=True; User ID=welcome; Password=abcd;")
                        .ShowSql()
               ).Mappings(m => m.FluentMappings.AddFromAssemblyOf<CustomerMap>())
               //.ExposeConfiguration(cfg => new SchemaUpdate(cfg).Execute(false, true))
               .ExposeConfiguration(cfg => new SchemaExport(cfg).Create(true,true))
               .ExposeConfiguration(ConfigureEnvers)
               .BuildSessionFactory();

private static void ConfigureEnvers(NHibernate.Cfg.Configuration nhConf)
{
var enversConf = new NHibernate.Envers.Configuration.Fluent.FluentConfiguration();
            enversConf.Audit<Customer>();
            nhConf.IntegrateWithEnvers(enversConf);
}

but when I try to add customer object; I am getting error- could not get next sequence value[SQL: select rev_id_seq.nextval from dual]
Any help would be appreciated. 

Thank you
Minal

Meenal Zodage

unread,
Feb 11, 2015, 11:34:04 AM2/11/15
to nhu...@googlegroups.com
Please ignore my previous message; Changed the code as follows and its working now !!
return dbConfiguration
                .Mappings(m => m.FluentMappings.AddFromAssemblyOf<LicenseClassMap>())
                .ExposeConfiguration(SetupEnvers)
                .ExposeConfiguration(cfg => new SchemaUpdate(cfg).Execute(false, true))                
                .BuildSessionFactory();

Alex Brown

unread,
Feb 12, 2015, 8:17:59 AM2/12/15
to nhu...@googlegroups.com
Do you have some more context around the error?
Stack trace perhaps?

Could you send the code of CustomerMap?

--
You received this message because you are subscribed to a topic in the Google Groups "nhusers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nhusers/IS5CWOLhqN4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nhusers+u...@googlegroups.com.

To post to this group, send email to nhu...@googlegroups.com.
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages