How do I generate ids with NHibernate and Firebird?

天涯浪子 提交于 2020-01-06 02:49:08

问题


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

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

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>

回答1:


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

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.

Here's the example of what I'm talking about:

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

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




回答2:


That looks all right. The problem is not the end bracket after ANML_EVNT, right?

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


</id>


来源:https://stackoverflow.com/questions/414889/how-do-i-generate-ids-with-nhibernate-and-firebird

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!