Error with hilo in NHibernate - “could not read a hi value - you need to populate the table”

倾然丶 夕夏残阳落幕 提交于 2019-12-20 19:56:12

问题


I've genereated a schema for my (SQL 2005) db using SchemaExport, and it's created a table

CREATE TABLE [dbo].[hibernate_unique_key](
    [next_hi] [int] NULL
) ON [PRIMARY]

When I try to add an entity, I get the error "could not read a hi value - you need to populate the table". What am I meant to do?

edit: I've inserted a 1 into the table, and it seems to work. Is this the correct value to have in there?


回答1:


NHibernate expects to find a value that stores the current hi value in that table, ie it first runs something like:

current_hi = [SELECT max(next_hi) FROM hibernate_unique_key].

So all you need to do is seed that table with an initial number, ie:

INSERT INTO hibernate_unique_key(next_hi) VALUES (0)


来源:https://stackoverflow.com/questions/1066098/error-with-hilo-in-nhibernate-could-not-read-a-hi-value-you-need-to-populat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!