StackOverFlowError while doing a One-To-One relati

2019-08-26 08:53发布

I have two tables Folder & VirtualSystemEntry I tried to follow this Dataneclous Turorial but it always results with StackOverFlowException here what I tried so far

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();
    }

Piece of the Exception Trace

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

So What am I doing wrong right here ?? by the way I'm Using GWT

1条回答
劫难
2楼-- · 2019-08-26 09:23

So your code VirtualSystemEntry(constructor) is calling your code Folder(constructor), which recurses (and you don't provide the code of those methods), likely the initialisation of those class variables "parent" and "vse" ... fix the initialisation ;-)

查看更多
登录 后发表回答