EclipseLink级联持续异常
当尝试保留具有映射到表主题的多对多字段的对象 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不完全确定语法,因为 Eclipse Workbench 似乎使用本机 EclipseLink ORM XML 文件,但使用标准 JPA XML 映射,您可以通过在其中添加
元素来设置级联
,类似这样:但是你真的应该改变你的习惯,Eclipse Workbench 并不适合 JPA 开发。在此 使用注释的工作台 线程中引用 James Sutherland 的话:
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: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: