开发者

Why does "increment" not set an identity seed in SQL Server 2008

开发者 https://www.devze.com 2023-02-04 06:59 出处:网络
I am trying to learn nhibernate 3.0 and I tried to put this in my mapping <id name=\"MovieId\"> <generator class=\"increment\" />

I am trying to learn nhibernate 3.0 and I tried to put this in my mapping

<id name="MovieId">
        <generator class="increment" />
    </id>

However w开发者_JS百科hen I generate my database it makes MovieId as a int(what I want) but it does not put identity seed on.

When I use

   <id name="MovieId">
        <generator class="native" />
    </id>

it works. I am not sure what native really is and why it works. I though increment does ints.


The generator should be "identity" or "native" instead of the "increment". "Native" uses "sequence" for databases like "PostGres" or "Oracle" and "identity" for MSSQL. It allows the same app to run on different databases without changing mappings.

"Increment" increments IDs in memory (instead of the DB) which creates several flaws like an inability to scale the application across multiple servers or use the same DB by multiple applications.

0

精彩评论

暂无评论...
验证码 换一张
取 消