StackOverFlowError while doing a One-To-One relationship in GAE Datastore using JPA 2.0

房东的猫 提交于 2019-12-11 18:14:21

问题


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:


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



来源:https://stackoverflow.com/questions/16855390/stackoverflowerror-while-doing-a-one-to-one-relationship-in-gae-datastore-using

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!