I'm newish to NHibernate, and am attempting to wire up to a DB2 table through the ISeries provider. The table has a BIGINT primary key that is auto generated as an identity. I've tried several values for the generator property of the id in my mapping file, and haven't had any success. The table def looks like so (field names changed):
CREATE TABLE SCHEMA/TABLE (
PKID BIGINT GENERATED ALWAYS AS IDENTITY (
START WITH 1 INCREMENT BY 1
NO MINVALUE NO MAXVALUE
NO CYCLE NO ORDER
CACHE 20)
,
SOMESTRING VARCHAR(50) CCSID 37 DEFAULT NULL,
FIRSTFK BIGINT NOT NULL,
SECONDFK BIGINT DEFAULT NULL,
ANOTHERSTRING VARCHAR(100) CCSID 37 DEFAULT NULL,
CONSTRAINT NISDEV/PK_TABLE PRIMARY KEY (PKID));
The mapping file looks like this:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Project.Domain.Thing, Project" table="TABLE">
<id name="ID" column="PKID" type="Int64">
<generator class="**???????**" />
</id>
<property name="SomeString" column="SOMESTRING" />
<property name="FirstFK" column="FIRSTFK"/>
<property name="SecondFK" column="SECONDFK"/>
<property name="AnotherString" column="ANOTHERSTRING"/>
</class>
</hibernate-mapping>
At first, I had the generator class set to "native," which, according to the documentation, picks "identity" for DB2. With "native" or "identity," I get "Null values not allowed in column PKID," and various other errors when I change the generator class to various other values.
I'm sure there's something small that I'm missing in the documentation, but is there any way I can get NHibernate to pick up the next value of a primary key that is a GENERATED IDENTITY in DB2 and handle it for me when I call Save()? Do I need to write a select somewhere that NHibernate can use to get the next value?
Thanks in advance.