简体   繁体   中英

Arango Edge Creation bug with Spring boot

I am creating a project with ArangoDb for my research. It is a backend project with Spring boot. I was following the tutorials here:

https://github.com/arangodb/spring-data-demo

Everything went well but when I tried creating a controller with the "Character" class. I get this error: java.lang.StackOverflowError: null

Upon further inspection, I found out that it is the mapping of children and parents that's creating this problem. In a separate project, I created a basic POJO (class Parts) with basic properties such as name, id and a collection of childParts similar to "childs" in your character class. I did all the mappings (with edges and all) and created the relationships. Then if I have two Parts Objects, P1 and P2, and I make P2 childPart of P1. The JSON response comes as P2 as child of P1 and then P1 as child of P2 and again P2 as child of P1 on and on. Its an infinite loop. Earlier I thought there was some problem with my implementation but when I downloaded the demo code. It has the same problem. Please let me know if there is a way to get around this or if I missed something.

The postman response of the tutorial code is actually an infinite loop. Something like this:

[
    {
        "id": "424543",
        "name": "Sansa",
        "surname": "Stark",
        "alive": true,
        "age": 13,
        "childs": [
            {
                "id": "424594",
                "name": "Ned",
                "surname": "Stark",
                "alive": false,
                "age": 41,
                "childs": [
                    {
                        "id": "424606",
                        "name": "Robb",
                        "surname": "Stark",
                        "alive": false,
                        "age": null,
                        "childs": [
                            {
                                "id": "424594",
                                "name": "Ned",
                                "surname": "Stark",
                                "alive": false,
                                "age": 41,
                                "childs": [
                                    {
                                        "id": "424606",
                                        "name": "Robb",
                                        "surname": "Stark",
                                        "alive": false,
                                        "age": null,
                                        "childs": [
                                            {
                                                "id": "424594",
                                                "name": "Ned",
                                                "surname": "Stark",
                                                "alive": false,
                                                "age": 41,
                                                "childs": [
                                                    {   

The annotations @Ref , @Relations , @To , and @From allow to set the field boolean lazy , which specifies whether the entity should be loaded lazily. Depending on how you modeled your entities and on which of the annotations above you use, I think you can solve the problem setting lazy = true in one of them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM