I'm trying to create my first test application with NHibernate following example in NHibernate 2.0 Beginners Guide. The example is using HiLo POID generator in mappings. I understand that this algorithm requires special database table to store current Hi value. But I don't understand how is this table created? Do I need to create table manually (I haven't found SQL script for this table) or should it be crated automatically by the session?
My current code is throwing exception with message: Invalid object name 'hibernate_unique_key' and table doesn't exist in my database.
The simpliest option how to generate database schema is to use the tool hbm2ddl: it is just the matter of configuring session factory:
Another option which I found recently is running shema export from the code. Here are details in another thread.
I suggest a hilo per table strategy, to do this you will need to create the table
manually
and then add some rows of data e.g.then add a row into the database for
every
table you wish to use the hilo for: e.g.Your mappings would then contain the following:-
and viola!