【发布时间】:2011-06-02 21:27:17
【问题描述】:
错误是: 错误:org.hibernate.QueryException:只能使用序列或插入后样式生成器生成 id 作为批量插入的一部分
HQL:
insert into CategoryProduct (category, product)
select c, p from Category c, Product p
where c.id = 252 and p.id = 554
categoryProduct 是一个嵌入了 Id 的实体:
@EmbeddedId
protected CategoryProductPK categoryProductPK;
提前致谢!
【问题讨论】:
-
看起来您可能没有在数据库中将 PK 列定义为自动增量。
-
是的,我的问题是:插入一行嵌入 id。我正在为此进行研究。可能不支持 HQL。