hibernate 中为什么生成的 insert 语句总是少了一个 test_id 字段?
hibernate 中为什么生成的 insert 语句总是少了一个 test_id 字段?
<hibernate-mapping>
<class name="test" table="test">
<id name="id" type="int" unsaved-value="0">
<column name="test_id" sql-type="int" not-null="true"/>
<generator class="native"/>
</id>
<property name="name" type="string">
<column name="test_name" sql-type="string" length="100" not-null="true"/>
</property>
</class>
</hibernate-mapping>
自动生成的SQL:
insert into test (test_name) values (?) select scope_id entity()
然后驱动程序报错说 id must not null!
哪里配置错了?
是不是表的id字段一定要设为自增?那这兼容性也不是很好!