NHibernate HiLo-适用于所有实体的一张表 [英] NHibernate HiLo - one table for all entities

查看:80
本文介绍了NHibernate HiLo-适用于所有实体的一张表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用NHibernate HiLo作为我的身份生成器.我的数据库中目前每个实体表都有一个单独的表.例如,我有Customer和CustomerKey表,每个表都有一个NextHiLo列.

I'm using NHibernate HiLo as my identity generator. I currently have a sepperate table in my database for each of my entity tables. For example I have Customer and CustomerKey table, each with a NextHiLo column.

拥有一个对其他所有表都具有键的表将是一件很棒的事情.想法是,如果我可以有一个这样的表:

What would be a great thing to have is a single table that holds key for all the others. Idealy would be if i could have a table like this:

TableName | NextHiLo
Customer | 19
Invoice | 5
Receipt | 3

如果NHibernate无法做到这一点,那么下一个最好的事情就是:

If that isnt't possible with NHibernate, the next best thing would be:

CustomerHiLo | InvoiceHiLo | ReceiptHiLo
19 | 5 | 3

以上两个选项中的任何一个是否可以实现-NHibernate生成的模式生成脚本似乎并不支持其中任何一个?

Is any of the two options above posible to achieve - the schema generation script produced by NHibernate doesn't apear to support any of them?

推荐答案

您是否尝试过使用hilo生成器的where属性? 像这样:

Have you tried using the where property of the hilo generator? Something like:

<class name="Customer">
    <id name="Id">
        <generator class="hilo">
            <param name="where">TableName = 'Customer'</param>
            ...
        </generator>
    </id>
    ...
</class>

这篇关于NHibernate HiLo-适用于所有实体的一张表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆