本文介绍了如何在一个新的数据库是hibernate_unique_key表产生的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建下面的示例 NHibernate的2.0初学者指南。这个例子是使用高住低训POID发电机映射。据我所知,这种算法需要特殊的数据库表来存储本届高值。但我不明白这是怎么表创建?我是否需要手动创建表(我还没有发现SQL脚本此表),还是应该由会话自动装箱?

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表产生的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!