如何使用NHibernate和Firebird生成ID? [英] How do I generate ids with NHibernate and Firebird?

查看:100
本文介绍了如何使用NHibernate和Firebird生成ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用NHibernate将一些新对象插入到firebird数据库中.

I'm trying to insert some new objects into a firebird database using NHibernate.

我收到错误消息无法获取下一个序列值[SQL:SQL不可用]"

I get the error "could not get next sequence value[SQL: SQL not available]"

这是我目前正在使用的映射.注意ANML_EVNT是我要使用的生成器的名称.

Here is the mapping I'm using at present. Note ANML_EVNT is the name of the generator I want to use.

    <id name="Id" column="ID" type="integer">
        <generator class="sequence">
            <param name="sequence">ANML_EVNT></param>   
        </generator>


    </id>

推荐答案

如果您仍在寻找答案,这就是我如何成功使用它.

If you still are looking for an answer here is how I've used it successfully.

我使用本机"生成器,因为在向程序添加对SQL Server的支持时,我唯一需要更改的是NHibernate的生成器类型,因为Firebird和SQL Server实现了自动递增身份"列不一样.在Firebird中,它使用了命名的生成器;在SQL Server中,它忽略了"sequence"参数,并使用了内置的自动增量.

I use the "native" generator because when adding support for SQL Server to our program the only thing in NHibernate I had to change was the generator types to "native" because Firebird and SQL Server implement their "auto incrementing identity" columns differently. In Firebird it used the named generator and in SQL Server it ignores the "sequence" parameter and uses the auto-increment built in.

这是我所谈论的例子:

<id name="Id" column="ID">
   <generator class="native">
      <param name="sequence">ANML_EVNT</param>
   </generator>
</id>

话虽如此,正如gcores回答的那样,您的配置中所有出现问题的地方就是ANML_EVNT之后的多余的>".

With all that said, as gcores answered, all that appears to be wrong with your config is the extra ">" after ANML_EVNT.

这篇关于如何使用NHibernate和Firebird生成ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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