问题描述
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?
我目前的code与消息引发异常:无效的对象名称是hibernate_unique_key和表没有在我的数据库存在
My current code is throwing exception with message: Invalid object name 'hibernate_unique_key' and table doesn't exist in my database.
推荐答案
我建议每桌战略希洛,要做到这一点,你需要创建表手动
和再加入一些行数据,例如中
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.
CREATE TABLE hibernate_unique_key (
TableName varchar(25) NOT NULL,
NextHi bigint NOT NULL
)
再添加一条记录到数据库中的每
表您希望使用的希洛的:如
then add a row into the database for every
table you wish to use the hilo for: e.g.
CmsLogin,10
Address, 10
您的映射将包含以下内容: -
Your mappings would then contain the following:-
<id name="Id" column="Id" unsaved-value="0">
<generator class="hilo">
<param name="column">NextHi</param>
<param name="where">TableName='CmsLogin'</param>
<param name="max_lo">100</param>
</generator>
</id>
和中提琴!
这篇关于如何在一个新的数据库是hibernate_unique_key表产生的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!