当插入行应返回用于主键列的序列号时的jpa(jpa when insert row should return the sequence number used for primary key col

编程入门 行业动态 更新时间:2024-10-19 16:28:41
当插入行应返回用于主键列的序列号时的jpa(jpa when insert row should return the sequence number used for primary key column)

我知道在sql(oracle)中我们可以使用“retruning into”但是在使用em.create()时可以使用JPA自动化。

I know in sql(oracle) we can use "retruning into" but is there something which can be automated using JPA when using em.create().

最满意答案

尝试使用em.merge(),它返回刚刚保留的附加实例。 在看到生成的主键之前,您可能必须使用em.flush()。

Try em.merge(), it returns the attached instance you just persisted. You might have to em.flush() before you see the generated primary key.

更多推荐

本文发布于:2023-07-07 21:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1068499.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:序列号   主键   insert   row   return

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!