0

I am trying to figure this strange mapping behaviour of nhibernate.

I Have a sequence ID in PostgreSQL and my mapping.hbm.xml file is this:

    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
      <class xmlns="urn:nhibernate-mapping-2.2" schema="core" name="Tecplas.Data.Models.Core.User, Tecplas.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="usuario">
        <id name="Id" type="System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
          <column name="usu_identi" />
          <generator class="native">
            <param name="sequence">seq_usuario</param>
          </generator>
        </id>
        <property name="CreatorProgram" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
          <column name="usu_prog_criacao" />
        </property>
        <property name="CreationDate" type="System.Nullable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
          <column name="usu_data_criacao" />
        </property>
        <property name="UpdateProgram" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
          <column name="usu_prog_alteracao" />
        </property>
        <property name="UpdateDate" type="System.Nullable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
          <column name="usu_data_alteracao" />
        </property>
        <property name="Login" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
          <column name="usu_login" />
        </property>
        <property name="Password" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
          <column name="usu_senha" />
        </property>
        <many-to-one class="Tecplas.Data.Models.Core.User, Tecplas.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="CreatorUser">
          <column name="usu_usu_criacao" />
        </many-to-one>
        <many-to-one class="Tecplas.Data.Models.Core.User, Tecplas.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="UpdateUser">
          <column name="usu_usu_alteracao" />
        </many-to-one>
      </class>
    </hibernate-mapping>

The error that i am getting is

  "Dialect does not support identity key generation"
  .... em NHibernate.Dialect.Dialect.get_IdentitySelectString()\r\n   em GetIdentitySelectString(Object )

I also changed the generator type to SEQUENCE but it gives me the same error.

Can anyone help?

Lelis718
  • 627
  • 7
  • 16

1 Answers1

0

The problem was with the nhibernate serialization.

I was serializing the model to json and i was not using the code from this link JSON.NET and nHibernate Lazy Loading of Collections

Actually this error is quite strange. My query was a 'GET' query and won't mess with the identity generation. But even with this, nhibernate was trying to generate an incorrect identity and threw me this weird exception.

Well. Problem solved.. maybe this help's someone :)

Community
  • 1
  • 1
Lelis718
  • 627
  • 7
  • 16