NHibernate Identity Fields

Getting started with NHibernate

How can I generate id fields in nHibernate using the Hilo algorithm?

+6
sql-server nhibernate
source share
2 answers

use class = "hilo":

<generator class="hilo"> 

Example:

 <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NHibernate__MyClass" assembly="NHibernate__MyClass"> <class name="MyClass" table="MyClass"> <id name="Id" type="int" column="ID"> <generator class="hilo"> </id> <property name="Name"> <column name="Name" not-null="true" /> </property> <property name="Value"> <column name="Value" not-null="true" /> </property> </class> </hibernate-mapping> 

I am simplified:

 <id name="Id"> <column name="ID" sql-type="int" not-null="true"/> <generator class="hilo" /> </id> 

in

 <id name="Id" type="int" column="ID"> <generator class="hilo"> </id> 

You may have some syntax error that confuses NHibernate.
If you can provide more detailed information about the code that runs before the crash, or something else that may seem important to you, this can speed up the speed at which your problem is resolved.

+7
source share

I have not watched screencasts yet. But nHibernate Summer should help you.

Sorry - I am not answering your original question.

+4
source share

All Articles