hibernate 自动编号的问题

来源:百度知道 编辑:UC知道 时间:2024/06/05 16:49:44
我在数据库中设置了
id int identity(1,1) not null primary key,
建好数据库
通过操作Hibernate的发生这样的错误:
Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]当 IDENTITY_INSERT 设置为 OFF 时,不能向表 'person' 中的标识列插入显式值。
不修改数据库的情况下怎么才能避免此类错误.

*.hbm.xml当中没有设置自动增长吧!要不就是设置错误!

<id name="id" type="integer">
<column name="id" />
<generator class="native" />
</id>
native为自动增长!

SQLServer里面的自增长为identity。
常用的还有:
Oracle:sequence
mysql:increment