使用JPA 2.0在GAE数据存储区中执行一对一关系时发生StackOverFlowError

时间:2013-05-31 10:40:14

标签: java google-app-engine jpa google-cloud-datastore datanucleus

我有两张桌子Folder& VirtualSystemEntry我尝试按照此Dataneclous Turorial进行操作,但此处始终以StackOverFlowException结果我到目前为止尝试了

Folder.java

@Entity
public class Folder implements IsSerializable{

    @Id
    @Column(name = "fvseID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
    private String fvseID;

    @OneToOne
    @JoinColumn(name="vseID")
    private VirtualSystemEntry vse=new VirtualSystemEntry();
}

VirtualSystemEntry.java

@Entity
public class VirtualSystemEntry implements IsSerializable {

    @Id
    @Column(name = "vseID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
    private String id;
    String label, image, tooltip;


    private int x, y, tray;

    @OneToOne(mappedBy="vse")
    Folder parent = new Folder();
    }

异常追踪的一部分

INTERNAL_SERVER_ERROR</pre></p><h3>Caused by:</h3><pre>java.lang.StackOverflowError
    at java.util.Hashtable.get(Hashtable.java:334)
    at java.util.Properties.getProperty(Properties.java:932)
    at java.lang.System.getProperty(System.java:653)
    at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:63)
    at com.cbd.shared.entities.VirtualSystemEntry.&lt;init&gt;(VirtualSystemEntry.java:28)
    at com.cbd.shared.entities.Folder.&lt;init&gt;(Folder.java:27)
    at com.cbd.shared.entities.VirtualSystemEntry.&lt;init&gt;(VirtualSystemEntry.java:28)
    at com.cbd.shared.entities.Folder.&lt;init&gt;(Folder.java:27)
    at com.cbd.shared.entities.VirtualSystemEntry.&lt;init&gt;(VirtualSystemEntry.java:28)
    at com.cbd.shared.entities.Folder.&lt;init&gt;(Folder.java:27)
    at com.cbd.shared.entities.VirtualSystemEntry.&lt;init&gt;(VirtualSystemEntry.java:28)
    at com.cbd.shared.entities.Folder..... and so on

那我在这里做错了什么?顺便说一句,我正在使用GWT

1 个答案:

答案 0 :(得分:1)

所以你的代码VirtualSystemEntry(constructor)正在调用你的代码Folder(constructor),它会递归(并且你不提供那些方法的代码),可能是那些类变量“parent”和“vse”的初始化“...修复初始化; - )