[coldbox-3.7] Handle identity field in MSSQL

Hi All,

anyone knows how to handle indetity field in coldbox, currently I have create the entity like this:

property name=“pay_ID” type=“numeric” notnull=“true” fieldtype=“id” generator=“increment”;

In ms sql database the field pay_id is set identity, but when I save it without posting this field I’ve got this error message:

Application Execution ExceptionError Type: Database : n/a

Error Messages: An exception occurred when committing the transaction.
The root cause of this exception was: coldfusion.orm.hibernate.HibernateSessionException: [Macromedia][SQLServer JDBC Driver][SQLServer]Cannot insert explicit value for identity column in table ‘TPROPayCond’ when IDENTITY_INSERT is set to OFF…

THanks for the help

If the table primary key is already set for identity, you need to set the generator to “identity”, also you probably want to make sure you define the unsavedvalue attribute (normally 0):

property name=“id” type=“Numeric” default=“0”
ormtype=“int”
column=“pay_ID”
fieldtype=“id”
generator="identity"
notnull=“true”
unsavedvalue=“0”;