Java-EE6:FetchType.LAZY与静态编织抛出奇怪的异常 [英] Java-EE6: FetchType.LAZY with static weaving throws strange exception

查看:394
本文介绍了Java-EE6:FetchType.LAZY与静态编织抛出奇怪的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的解决方案包含3个不同的项目:

My Solution consists of 3 different projects:


  • 使用Netbeans自动生成的Facade来管理实体类和EJB的项目persistence.xml

  • EJB project with Netbeans auto-generated Facades to manage Entity classes and the persistence.xml

包含所有@Entity带注释和静态编织的数据库类以及用于Facade ejb的远程接口的类库(在EJB和stand之间共享 - 单独的客户端)

Class-Library that holds all @Entity annotated and statically weaved database classes and the remote interfaces for the facade ejb's (shared between EJB and stand-alone client)

主要由Swing GUI类组成的独立客户端

Stand-alone Client that consists mainly of Swing GUI classes

我使用Glassfish 3.1.2,Eclipselink 2.3作为JPA-provider,Netbeans 7.1.1和MySQL数据库。我配置了一个Ant-task,它基于persistence.xml静态编织我的实体类。

I use Glassfish 3.1.2, Eclipselink 2.3 as JPA-provider, Netbeans 7.1.1 and a MySQL database. I configured an Ant-task that statically weaves my entity classes on the basis of the persistence.xml.

我有几个@OneToOne,@ ManyToOne和@ManyToMany注释之间的关系用fetch = FetchType.LAZY装饰的实体。

I have several @OneToOne, @ManyToOne and @ManyToMany annotated relations between the entities decorated with fetch=FetchType.LAZY.

现在我一直遇到以下错误:

Now I get all along the following errors:

Exception in thread "Mainframe Loader" Local Exception Stack: 
Exception [EclipseLink-7242] (Eclipse Persistence Services - 2.3.2.v20111125-r10461):     org.eclipse.persistence.exceptions.ValidationException
Exception Description: An attempt was made to traverse a relationship using indirection that had a null Session.  This often occurs when an entity with an uninstantiated LAZY relationship is serialized and that lazy relationship is traversed after serialization.  To avoid this issue, instantiate the LAZY relationship prior to serialization.
 at org.eclipse.persistence.exceptions.ValidationException.instantiatingValueholderWithNullSession(ValidationException.java:998)
 at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:220)
 at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:88)
 at org.eclipse.persistence.indirection.IndirectList.buildDelegate(IndirectList.java:244)
 at org.eclipse.persistence.indirection.IndirectList.getDelegate(IndirectList.java:414)
 at org.eclipse.persistence.indirection.IndirectList.size(IndirectList.java:752)
 at ch.lawsuite.gui.mail.PosteingangUI.updateDokumentTable(PosteingangUI.java:47)
 at ch.lawsuite.gui.mail.MailboxUI.updateDokumentTables(MailboxUI.java:81)
 at ch.lawsuite.gui.mail.MailboxUI.initMailboxes(MailboxUI.java:37)
 at ch.lawsuite.gui.mail.MailboxUI.<init>(MailboxUI.java:23)
 at ch.lawsuite.gui.MainframeUI.initModules(MainframeUI.java:191)
 at ch.lawsuite.gui.login.LoginUI$MainframeLoader.run(LoginUI.java:131)

任何帮助都非常感谢。我已经完全陷入了这个问题的困境超过一个星期了: - (

Any help is highly appreciated. I completely got deadlocked with this issue for more than a week now :-(

非常感谢提前!

推荐答案

一旦将实体传递给远程客户端 - 您无法加载未加载的惰性属性。您需要确保它们在外观中加载(触摸它们或其他东西)远程传递它们。静态编织与此无关。(好吧,自动过程与静态/动态/无编织不同 - 但从概念上讲,对于我们来说开发人员没有区别)

Once the entity is passed to a remote client - you can't load none-loaded lazy properties. You need to make sure they are loaded (touch them or something) in the facade that passes them remotely. Static weaving has nothing to do with this. (Well, the automatic process is different with static/dynamic/no weaving - but conceptually for us as developers there is no difference)

这篇关于Java-EE6:FetchType.LAZY与静态编织抛出奇怪的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆