Paul
Paul

Reputation: 12799

Nhibernate Mapping by Code conventions to Postgres Sequence

I´m using PostGres 8.3 and have NHibernate working fine with database... I´m creating a Conventions file and I´m having problem to configure the Primary key sequence... All my tables have a primary key called ID, so I did that :

...
mapper.BeforeMapClass += (modelInspector, type, classCustomizer) => {
            classCustomizer.Id(c => c.Column("ID"));
            classCustomizer.Id(c => c.Generator(Generators.Sequence));
};

When I try to Save a instance, I got that error:

ERROR: 42P01: relation "hibernate_sequence" does not exist

How Can I create a convention to that?

Thanks

Upvotes: 0

Views: 1114

Answers (1)

Leaf
Leaf

Reputation: 26

have a look at How to properly use NHibernate By Code to get the next Sequence in Oracle?

Id(u => u.Id, map =>
            {
                map.Column("id");
                map.Generator(Generators.Sequence,
                              gmap => gmap.Params(new {sequence = "seq_name"}));
            });

Upvotes: 1

Related Questions