{"id":16869500,"url":"https://github.com/shakuzen/aggregate-child-update-sample","last_synced_at":"2026-04-16T12:01:40.350Z","repository":{"id":86165204,"uuid":"80616839","full_name":"shakuzen/aggregate-child-update-sample","owner":"shakuzen","description":"Spring Data REST issue repro project","archived":false,"fork":false,"pushed_at":"2017-02-02T10:34:15.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-16T01:36:03.432Z","etag":null,"topics":["spring-data-jpa","spring-data-rest"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shakuzen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-01T12:13:06.000Z","updated_at":"2017-02-03T09:27:01.000Z","dependencies_parsed_at":"2023-03-13T08:43:35.864Z","dependency_job_id":null,"html_url":"https://github.com/shakuzen/aggregate-child-update-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shakuzen/aggregate-child-update-sample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shakuzen%2Faggregate-child-update-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shakuzen%2Faggregate-child-update-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shakuzen%2Faggregate-child-update-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shakuzen%2Faggregate-child-update-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shakuzen","download_url":"https://codeload.github.com/shakuzen/aggregate-child-update-sample/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shakuzen%2Faggregate-child-update-sample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31884929,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T11:36:10.202Z","status":"ssl_error","status_checked_at":"2026-04-16T11:36:09.652Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["spring-data-jpa","spring-data-rest"],"created_at":"2024-10-13T15:01:00.983Z","updated_at":"2026-04-16T12:01:40.330Z","avatar_url":"https://github.com/shakuzen.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"Spring Data REST JSON patch issue repro project\n======\n\nJSON Patch ([RFC6902](https://tools.ietf.org/html/rfc6902)) requests to add to a collection of entities \nunder an aggregate root are failing with Hopper and Ingalls but working with Gosling.\n \nThis can be tested by switching the Spring Boot parent version used in the POM and following the steps below.\n\n| Spring Boot | Spring Data | JSON Patch? |\n| ----------- | ----------- | ----------- |\n|    1.3.x    |   Gosling   |    Works    |\n|    1.4.x    |    Hopper   |    Error    |\n|    1.5.x    |   Ingalls   |    Error    |\n\nIntegration test reproduction\n-------\nRun the single test class `AggregateChildUpdateSampleApplicationTests` to verify the JSON Patch behavior.\nUnfortunately, I could not figure out a way to write the web integration test so that it compiles on all \nversions of Spring Boot from 1.3.x to 1.5.x due to deprecations and removals of test annotations.\n\nTherefore, some work of uncommenting and commenting annotations and imports is needed when switching between\nSpring Boot versions. The committed version runs with Spring Boot 1.5.x. \nTo switch to Spring Boot 1.3.x compatible version, uncomment the commented portions and comment the \n`@SpringBootTest` annotation and import.\n\nManual reproduction\n--------\n\nExample requests shown using [HTTPie](https://httpie.org/).\n\n1. Create a new `Post`\n\n```\n$ http POST :8080/posts title=\"My first post\" -v\nPOST /posts HTTP/1.1\nAccept: application/json, */*\nAccept-Encoding: gzip, deflate\nConnection: keep-alive\nContent-Length: 26\nContent-Type: application/json\nHost: localhost:8080\nUser-Agent: HTTPie/0.9.8\n\n{\n    \"title\": \"My first post\"\n}\n\nHTTP/1.1 201 Created\nContent-Type: application/json;charset=UTF-8\nDate: Wed, 01 Feb 2017 11:47:33 GMT\nLocation: http://localhost:8080/posts/1\nServer: Apache-Coyote/1.1\nTransfer-Encoding: chunked\nX-Application-Context: application\n\n{\n    \"_links\": {\n        \"post\": {\n            \"href\": \"http://localhost:8080/posts/1\"\n        },\n        \"self\": {\n            \"href\": \"http://localhost:8080/posts/1\"\n        }\n    },\n    \"comments\": [],\n    \"title\": \"My first post\"\n}\n```\n\n2. Add a `Comment` with JSON Patch\n\n```\n$ echo '[{\"op\":\"add\", \"path\":\"/comments/-\", \"value\":{\"content\": \"Cool post\"}}]' | http PATCH :8080/posts/1 Content-Type:application/json-patch+json -v\nPATCH /posts/1 HTTP/1.1\nAccept: application/json, */*\nAccept-Encoding: gzip, deflate\nConnection: keep-alive\nContent-Length: 71\nContent-Type: application/json-patch+json\nHost: localhost:8080\nUser-Agent: HTTPie/0.9.8\n\n[\n    {\n        \"op\": \"add\",\n        \"path\": \"/comments/-\",\n        \"value\": {\n            \"content\": \"Cool post\"\n        }\n    }\n]\n\nHTTP/1.1 200 OK\nContent-Type: application/json;charset=UTF-8\nDate: Wed, 01 Feb 2017 11:57:01 GMT\nServer: Apache-Coyote/1.1\nTransfer-Encoding: chunked\nX-Application-Context: application\n\n{\n    \"_links\": {\n        \"post\": {\n            \"href\": \"http://localhost:8080/posts/1\"\n        },\n        \"self\": {\n            \"href\": \"http://localhost:8080/posts/1\"\n        }\n    },\n    \"comments\": [\n        {\n            \"content\": \"Cool post\"\n        }\n    ],\n    \"title\": \"My first post\"\n}\n```\n\nWith Hopper or Ingalls, the following error occurs instead of \nsuccessfully adding the `Comment` as above (when using Gosling).\n\n```\n{\n    \"cause\": {\n        \"cause\": null,\n        \"message\": \"Expression [comments.-] @8: EL1049E: Unexpected data after '.': 'minus(-)'\"\n    },\n    \"message\": \"Could not read PATCH operations! Expected application/json-patch+json!; nested exception is org.springframework.expression.spel.SpelParseException: Expression [comments.-] @8: EL1049E: Unexpected data after '.': 'minus(-)'\"\n}\n```\n\nThis alludes to a problem with parsing the syntax for adding an element \nto the end of an array using the `-` (minus) index.\n\nHowever, even if a request to add the entire array is used, the request fails with a different error:\n\n```\n$ echo '[{\"op\":\"add\", \"path\":\"/comments\", \"value\":[{\"content\": \"Cool post!\"}]}]' | http PATCH :8080/posts/1 Content-Type:application/json-patch+json -v\nPATCH /posts/1 HTTP/1.1\nAccept: application/json, */*\nAccept-Encoding: gzip, deflate\nConnection: keep-alive\nContent-Length: 72\nContent-Type: application/json-patch+json\nHost: localhost:8080\nUser-Agent: HTTPie/0.9.8\n\n[\n    {\n        \"op\": \"add\",\n        \"path\": \"/comments\",\n        \"value\": [\n            {\n                \"content\": \"Cool post!\"\n            }\n        ]\n    }\n]\n\nHTTP/1.1 400\nConnection: close\nContent-Type: application/json;charset=UTF-8\nDate: Wed, 01 Feb 2017 12:02:33 GMT\nTransfer-Encoding: chunked\nX-Application-Context: application\n\n{\n    \"cause\": {\n        \"cause\": {\n            \"cause\": null,\n            \"message\": \"failed to lazily initialize a collection, could not initialize proxy - no Session\"\n        },\n        \"message\": \"Could not read [{\\\"content\\\":\\\"Cool post!\\\"}] into class org.hibernate.collection.internal.PersistentSet!\"\n    },\n    \"message\": \"Could not read an object of type class com.example.data.Post from the request!; nested exception is org.springframework.data.rest.webmvc.json.patch.PatchException: Could not read [{\\\"content\\\":\\\"Cool post!\\\"}] into class org.hibernate.collection.internal.PersistentSet!\"\n}\n```\n\nRelated links\n-------\n\n* https://stackoverflow.com/questions/34843297/modify-onetomany-entity-in-spring-data-rest-without-its-repository\n* https://jira.spring.io/browse/DATAREST-813\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshakuzen%2Faggregate-child-update-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshakuzen%2Faggregate-child-update-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshakuzen%2Faggregate-child-update-sample/lists"}