问题
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