How do I create IDs using NHibernate and Firebird?

I am trying to insert some new objects into firebird database using NHibernate.

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

Here is the mapping I'm currently using. 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


source to share


2 answers


If you are still looking for an answer, this is how I used it successfully.

I am using the "native" generator because while adding SQL Server support to our program, the only thing I had to change in NHibernate is the generator types for the "native" ones, because Firebird and SQL Server use their "auto incrementing identity" columns otherwise. In Firebird it used a named generator and in SQL Server it ignores the "sequence" parameter and uses the built-in autoincrement.

Here's an 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 being said, as gcores answered, all that seems to be wrong with your config is the extra ">" after ANML_EVNT.

+4


source


Everything looks good. The problem isn't with the end brace after ANML_EVNT, right?



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


</id>

      

+2


source







All Articles