hibernate 中为什么生成的 insert 语句总是少了一个 test_id 字段?

wealth wealth 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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字段一定要设为自增?那这兼容性也不是很好!
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
wealth
Java EE 67,535 成员 225,843 内容