spring-projects / spring-data-rest

Simplifies building hypermedia-driven REST web services on top of Spring Data repositories
https://spring.io/projects/spring-data-rest
Apache License 2.0
916 stars 563 forks source link

RFC 6902 style patch operation not working anymore [DATAREST-813] #1189

Closed spring-projects-issues closed 7 years ago

spring-projects-issues commented 8 years ago

Florin Duroiu opened DATAREST-813 and commented

I have just upgraded from Spring Boot 1.4.0.M1 to 1.4.0.M2 and I noticed that the RFC6902 style patch operations don't seem to work for me anymore. Test project: https://github.com/florind/spring-boot-rfc6902 I'm getting now:

Could not read an object... nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1034E:(pos 0): A problem occurred whilst attempting to set the property 'payment': Type conversion failure

The data structure like this:

@Data
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
@EntityListeners(AuditingEntityListener.class)
@Entity(name = "POLICY_BUNDLE")
@NoArgsConstructor
public class PolicyBundle  implements Identifiable<Long> {
    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Embedded
    @Valid private Payment payment;

    @Embeddable @Data
    public static class Payment {
        public enum PaymentFrequency {Monthly, Quarterly, Yearly}
        @NotNull private String price;
        @NotNull private PaymentFrequency frequency;
    }
}

and the PATCH operation is

[
    {"op":"add","path":"/payment","value":{"price":"EUR 19.00","frequency":"Monthly"}}
]

Now I am seeing that org.springframework.expression.spel.support.StandardTypeConverter::convertValue(…) catches a ConversionException with message org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [com.domain.policy.PolicyBundle] to type [@javax.persistence.Embedded @javax.validation.Valid com.domain.policy.PolicyBundle$Payment] and rethrows a SpelEvaluationException that bubbles up eventually into the error above


Affects: 2.5.1 (Hopper SR1)

Reference URL: https://github.com/spring-projects/spring-boot/issues/5742

Issue Links:

Backported to: 2.5.7 (Hopper SR7)

1 votes, 3 watchers

spring-projects-issues commented 7 years ago

Tommy Ludwig commented

I'm not certain the root cause is the same, but I am also unable to successfully use JSON Patch for my use case with Hopper or Ingalls. I have made a reproduction repository here: https://github.com/shakuzen/aggregate-child-update-sample

spring-projects-issues commented 7 years ago

Oliver Drotbohm commented

Would you mind turning the manual testing procedure into an integration test so that I can more reliably execute it repeatedly?

spring-projects-issues commented 7 years ago

Florin Duroiu commented

I'm updating my findings since I'm the reporter: I just checked the same with Spring Boot releases beyond 1.4.0.M2 and the issue above is gone when using Spring Boot 1.4.x.RELEASE and 1.5.x.RELEASE. I've updated my linked github project accordingly. Tommy, what you see might be a different issue

spring-projects-issues commented 7 years ago

Oliver Drotbohm commented

That's helpful, Florin Duroiu. I was just about to investigate your case, too. I'll just mark this one as resolved against latest Hopper and Ingalls releases and go ahead with a new ticket for Tommy's case. That indeed is still broken, as we apparently use ~ instead of - to indicate "append" on a collection property