EclipseLink级联持续异常

发布于 2024-09-14 19:55:26 字数 371 浏览 0 评论 0原文

当尝试保留具有映射到表主题的多对多字段的对象 Word() 时,我收到“在同步期间,通过未标记级联 PERSIST 的关系找到了新对象”。关系桥表是Topic_links。使问题变得复杂的是,我总是使用 Eclipse Workbench 来设置我的实体,这使得很难找到解决方案,因为大多数人使用注释来建议答案,而工作台不使用注释。我尚未在工作台中找到将关系的 CASCADE 选项设置为 PERSIST 的方法。我已将以下条目添加到 persistence.xml:

<property name="eclipselink.persistence-context.persist-on-commit" value="true"/>

仍然抛出异常。

I am getting "During synchronization a new object was found through a relationship that was not marked cascade PERSIST" when attempting to persist an object Word() that has a Many-To-Many field mapping to a table Topics. The relations bridge table is Topic_links. What complicates the problem is that I always use the Eclipse Workbench to setup my entities, which makes it hard to find solutions as most people suggest answers using annotations, which the workbench does not use. I have not found a way in the workbench to set the CASCADE option for the relationship to PERSIST. I have added the following entry to the persistence.xml:

<property name="eclipselink.persistence-context.persist-on-commit" value="true"/>

The exception is still being thrown.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心病无药医 2024-09-21 19:55:26

我不完全确定语法,因为 Eclipse Workbench 似乎使用本机 EclipseLink ORM XML 文件,但使用标准 JPA XML 映射,您可以通过在其中添加 元素来设置级联,类似这样:

<many-to-many name="projects" target-entity="Project">
    <join-table name="PROJ_EMP">
        <join-column name="EMP_ID" />
        <inverse-join-column name="PROJ_ID" />
    </join-table>
    <cascade>
        <cascade-persist/>
    </cascade>
</many-to-many>

但是你真的应该改变你的习惯,Eclipse Workbench 并不适合 JPA 开发。在此 使用注释的工作台 线程中引用 James Sutherland 的话:

EclipseLink Workbench 是 UI
对于本机(旧)EclipseLink ORM
XML文件,OXM和EIS,是不是这个意思
用于 JPA 开发。日食大理,
Oracle JDeveloper 或其他此类 JPA
为此应使用工具。

I'm not totally sure of the syntax because it appears that the Eclipse Workbench uses native EclipseLink ORM XML file but with standard JPA XML mappings, you can setup cascading by adding a <cascade> element inside the <many-to-many>, something like this:

<many-to-many name="projects" target-entity="Project">
    <join-table name="PROJ_EMP">
        <join-column name="EMP_ID" />
        <inverse-join-column name="PROJ_ID" />
    </join-table>
    <cascade>
        <cascade-persist/>
    </cascade>
</many-to-many>

But you should really change your habits, Eclipse Workbench is not ideal for JPA development. Quoting James Sutherland in this Workbench to use annotations thread:

The EclipseLink Workbench is the UI
for the native (old) EclipseLink ORM
XML file, OXM and EIS, is it not meant
for JPA development. Eclipse Dali,
Oracle JDeveloper or other such JPA
tools should be used for this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文