Auto Increment in FLuent Nhibernate and PostgreSQL

1,419 views
Skip to first unread message

Rivera

unread,
Oct 6, 2010, 9:46:13 PM10/6/10
to fluent-n...@googlegroups.com

Hai, I`m Newbie in Fluent Nhibernate.. I have postgreSql Database and what i want is generated id with auto increment.. i have no see feature auto increment in Postgres and i was understand that for use auto increment in postgreSql i must create sequence..

there is other way beside sequence?

if create sequence is the only way, can You tell me how I mapping it? I was tried use this and not success :

mapping.Id(x => x.Id, "id").GeneratedBy.Sequence("hibernate-sequence");

i was created hibernate-sequence before

Regards

Yann ROBIN

unread,
Oct 7, 2010, 7:46:45 AM10/7/10
to fluent-n...@googlegroups.com
Hi,

PostgreSQL have "serial" types that create the sequence and set the
default value field to the sequence.
So if you use this feature, you only need to set GeneratedBy.Identity()

--
Yann

Oskar Berggren

unread,
Oct 7, 2010, 8:09:46 AM10/7/10
to fluent-n...@googlegroups.com
Though you should also be aware of the consequences of letting the
database generate the id. See for example:
http://nhforge.org/blogs/nhibernate/archive/2009/03/20/nhibernate-poid-generators-revealed.aspx


/Oskar


2010/10/7 Yann ROBIN <me....@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group.
> To post to this group, send email to fluent-n...@googlegroups.com.
> To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages