Asela Gunwardena
Asela Gunwardena

Reputation: 77

Configuring hilo "could not get or update next value[SQL: ]"

I want to configure NHibernate to with hilo generator, but the following configuration throws a GenericADO exception saying "could not get or update next value[SQL: ]". If the generator class is 'identity' it works as expected.

Note. I set the "Is Identity" to 'No' on the SQL Server end when using the hilo generator.

<class name="Model.Session, Domain" table="Session">
  <id name="SessionID" column="SessionId" type="Int32">
    <!--<generator class="identity" />-->
    <generator class="hilo" /
  </id>
  <property name="SessionToken" column="SessionToken" type="String" length="80"/>
  <property name="UserID" column="UserId" type="Int32"/>
</class>

Upvotes: 1

Views: 2435

Answers (1)

rebelliard
rebelliard

Reputation: 9611

Probably the table that NHibernate uses to get the "low" values from the server has not been created, either manually or by schema generation.

The basic idea is that you have two numbers to make up a primary key- a "high" number and a "low" number. A client can basically increment the "high" sequence, knowing that it can then safely generate keys from the entire range of the previous "high" value with the variety of "low" values.

Upvotes: 2

Related Questions