Golan Kiviti
Golan Kiviti

Reputation: 4245

Nhibernate - Generated by sequence with oracle

I am using nhibernate and I have crossed an issue, I want to know how the nhibernate - GeneratedBy Sequence works. Is it generating an id from the sequence when I'm trying to save no matter what? for example, if I have an entity which I mapped it to generate the id from the sequence, and I set the id to a different value than 0, will it generate the id from the sequence? or just save as the given id?

Thanks.

Upvotes: 0

Views: 755

Answers (1)

Frédéric
Frédéric

Reputation: 9864

Well, try it, and you will probably see it will generate an id from the sequence. I do not know of any id generator allowing to explicitly set the id except the assigned generator.

You may be interested in the Creating a custom id generator tutorial if you actually need some kind of hybrid sequence/assigned generator. It should help you write your own. But its semantic will be tricky: how will you ensure an assigned id will not be issued later on by the sequence itself?

Upvotes: 1

Related Questions