{"id":16619988,"url":"https://github.com/cepr0/put-doesnt-work-in-sdr","last_synced_at":"2025-08-31T04:15:47.786Z","repository":{"id":130472389,"uuid":"99854321","full_name":"Cepr0/put-doesnt-work-in-sdr","owner":"Cepr0","description":"Spring Data REST - PUT does not work since v.2.5.7-RELEASE","archived":false,"fork":false,"pushed_at":"2017-08-14T21:05:34.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T07:19:09.990Z","etag":null,"topics":["bug","error","rest","spring-boot","spring-data-rest"],"latest_commit_sha":null,"homepage":"","language":"Java","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/Cepr0.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-08-09T21:28:51.000Z","updated_at":"2017-08-10T14:24:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"9914f03c-ab28-4047-855c-7c006febd339","html_url":"https://github.com/Cepr0/put-doesnt-work-in-sdr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Cepr0/put-doesnt-work-in-sdr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fput-doesnt-work-in-sdr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fput-doesnt-work-in-sdr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fput-doesnt-work-in-sdr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fput-doesnt-work-in-sdr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cepr0","download_url":"https://codeload.github.com/Cepr0/put-doesnt-work-in-sdr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fput-doesnt-work-in-sdr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272937339,"owners_count":25018360,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["bug","error","rest","spring-boot","spring-data-rest"],"created_at":"2024-10-12T02:43:14.646Z","updated_at":"2025-08-31T04:15:47.766Z","avatar_url":"https://github.com/Cepr0.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Spring Data REST - PUT request does not work properly since v.2.5.7!\n\nSince version 2.5.7 Spring Data REST does not properly perform a **PUT** request\nto update resource which has associated resources. Unlike PATCH request that works as expected!\n\nFor example, `Person` has a many-to-one association with `Addres`. If we perform\na PUT request with SDR v.2.5.6 (Spring Boot v.1.4.3) then all works OK. But if we switch\nto version 2.5.7 (i.e. to Spring Boot v.1.4.4) then we get an error:\n\n```Can not construct instance of Address: no String-argument constructor/factory method to deserialize from String value```\n\nThe same happens with other types of associations, for example with one-to-many (uni- and bidirectional) - \nsee the application code and tests.\n\nThis problem is present in all versions of the Spring Boot since 1.4.4 including the latest stable 1.5.6 version, \nas well as the newest 2.0.0-SNAPSHOT version.\n\nTo work around this situation we can just switch to SDR v.2.5.6 (Spring Boot v.1.4.3).\n\n### UPDATE #1\n\nI found how to avoid the error `Can not construct instance of Address: no String-argument constructor/factory\nmethod to deserialize from String value`. Since I'm using [Lombok](https://projectlombok.org/) in this project,\nit is necessary to tell Lombok to suppress using the `@ConstructorProperties` annotation in \n[generated constructors](https://projectlombok.org/features/constructor).\nSo I set `lombok.anyConstructor.suppressConstructorProperties=true` in the 'lombok.config' file and the error was gone.\n\nBut a new problem was found - PUT request does not update associated objects at all! \nThe example below is demonstrating this behavior. We are trying to update Person by changing his \nAddress from `address/1` (initial value) to `address/2` - then it remains the same: `address/1`:      \n\n```java\n@Entity\npublic class Person extends BaseEntity {\n    \n    private String name;\n    \n    @ManyToOne\n    private Address address;\n\n    // other stuff\n}\n\n@Entity\npublic class Address extends BaseEntity {\n    \n    private String street;\n    \n    // other stuff    \n}\n```\n\nTrying to update Person: \n\n    PUT http://localhost:8080/api/persons/1\n\n```json\n{\n\t\"name\": \"person1u\",\n\t\"address\": \"http://localhost:8080/api/addresses/2\"\n}\n```\n\nGetting the correct response:\n\n```json\n{\n    \"name\": \"person1u\",\n    \"_links\": {\n        \"self\": {\n            \"href\": \"http://localhost:8080/api/persons/1\"\n        },\n        \"person\": {\n            \"href\": \"http://localhost:8080/api/persons/1\"\n        },\n        \"address\": {\n            \"href\": \"http://localhost:8080/api/persons/1/address\"\n        }\n    }\n}\n``` \n\nAnd checking for a 'new' Address of Person - address was not updated: \n\n    GET http://localhost:8080/api/persons/1/address\n\n```json\n{\n    \"street\": \"address1\",\n    \"_links\": {\n        \"self\": {\n            \"href\": \"http://localhost:8080/api/addresses/1\"\n        },\n        \"address\": {\n            \"href\": \"http://localhost:8080/api/addresses/1\"\n        }\n    }\n}\n```\n\n(The PATCH request still works as expected)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcepr0%2Fput-doesnt-work-in-sdr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcepr0%2Fput-doesnt-work-in-sdr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcepr0%2Fput-doesnt-work-in-sdr/lists"}