2016-06-29 84 views
0

我正在使用Microsoft SQL Server數據庫。
在我的Hibernate映射文件,我已經聲明爲無法在休眠表中插入記錄

<id name="item_Group_Sid" type="int" column="ITEM_GROUP_SID" > 
    <generator class="native"/> 
</id>. 

我試圖插入表中的一條記錄的主鍵。 但我得到錯誤,如

不允許DEFAULT或NULL作爲顯式標識值。

我的hibernate.cfg.xml是

<hibernate-configuration> 
    <session-factory> 
    <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property> 
    <property name="hibernate.connection.url">**</property> 
    <property name="hibernate.connection.username">**</property> 
    <property name="hibernate.connection.password">**</property> 
    <property name="hibernate.dialect">org.hibernate.dialect.DB2Dialect</property> 
    <property name="hibernate.show_sql">true</property> 
    <property name="hibernate.format_sql">true</property> 

    <mapping resource="ItemGroup.hbm.xml"/> 
    </session-factory> 
</hibernate-configuration> 
+0

分享您hibernate.cfg.xml文件在這裏 –

+0

嗨Ransher辛格,感謝您的答覆。 我已經用hibernate.cfg.xml更新了這個問題。 請告訴我 – KKR

回答

0

更改hibernate.dialect

<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property> 
+0

現在我可以插入了。謝謝Ransher Singh – KKR

+0

很好..我們建議您從問題的上面的cfg.xml文件中刪除url,username和pwd :) –