0

我有两张桌子FolderVirtualSystemEntry我试图遵循这个Datanecous Turorial但它总是在StackOverFlowException这里得到我迄今为止尝试过的结果

文件夹.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();
}

虚拟系统入口.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

4

1 回答 1

1

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

于 2013-05-31T13:02:16.387 回答