Json does not map an object when it is already in another

0

I have the following case, an @RestController returns a json that comes from mapping some entities with SpringData, in the service everything returns well (the list that comes from the DB), but when it returns with:

return new ResponseEntity<>(entidades, HttpStatus.OK);

In the json that returns if a "service" is already in a previous object does not return it correctly, it brings me to the entity of id: 2 (entity2) services 3 and 4 and for the entity id: 3 ( entity3) malformed service 4 (because it is already in the entity id: 2):

   [
        {
            "id": 1,
            "nombre": "entidad1",
            "repetible": true,
            "servicios": [
                {
                "id": 2,
                "nombre": "servicio2",
                "codigo": "002",
                "tipo": "servicio",
                "proveedor": "proveedor"
                }
            ],
            "entidadesDatos": [],
            "mensajesEntidadesDatos": []
        },
        {
            "id": 2,
            "nombre": "entidad2",
            "repetible": true,
            "servicios": [
                {
                    "id": 4,
                    "nombre": "servicio4",
                    "codigo": "004",
                    "tipo": "servicio",
                    "proveedor": "proveedor"
                },
                {
                    "id": 3,
                    "nombre": "servicio3",
                    "codigo": "003",
                    "tipo": "servicio",
                    "proveedor": "proveedor"
                }
            ],
            "entidadesDatos": [],
            "mensajesEntidadesDatos": []
        },
        {
            "id": 3,
            "nombre": "entidad3",
            "repetible": false,
            "servicios": [
                4
            ],
            "entidadesDatos": [],
            "mensajesEntidadesDatos": []
        }
  ]

Again, I reiterate that the list when reviewing it is fine, it is when Jackson pauses the list that this happens.

I have no idea why something like this could happen.

Greetings!

    
asked by zerocool 10.04.2018 в 16:27
source

0 answers