在Spring数据中,rest可以通过POST/parent/{parentId}/nested将嵌套的@OneToMany对象添加到父对象中吗?

在Spring数据中,rest可以通过POST/parent/{parentId}/nested将嵌套的@OneToMany对象添加到父对象中吗?,rest,one-to-many,spring-data-rest,spring-web,Rest,One To Many,Spring Data Rest,Spring Web,我有父对象和嵌套对象。我可以使用get/parent/{parentId}/nested获取嵌套的列表,但我无法成功地发布/放置到该列表中。在POST结果中,我得到HTTP 204,父对象的嵌套对象列表为空 在日志中,我看到Hibernate没有在数据库中插入任何内容。 在调试期间,我看到用于反序列化的Jackson对象映射器将“org.springframework.hateoas.Resources”作为JavaType 以下是我的帖子的真实例子: curl'http://localhost

我有父对象和嵌套对象。我可以使用
get/parent/{parentId}/nested
获取嵌套的列表,但我无法成功地发布/放置到该列表中。在POST结果中,我得到HTTP 204,父对象的嵌套对象列表为空

在日志中,我看到Hibernate没有在数据库中插入任何内容。 在调试期间,我看到用于反序列化的Jackson对象映射器将“
org.springframework.hateoas.Resources
”作为JavaType

以下是我的帖子的真实例子:
curl'http://localhost:8000/api/users/402880e554b8f7960154b8f7adbc0000/orders/'-i-X POST-H'授权:Basic OLOLO='-H'接受:application/json'-H'设备currencycode:USD'-H'内容类型:application/json;charset=UTF-8'-d'{“orderPrice”:0,“tax”:0,“shippingCost”:0,“credits”:0,“addresses”:[{“Figli”,“lastName”:“Migli”,“zipCode”:“5555”,“city”:“Riga”,“country”:“Tlmltr”,“phone”:“7777”,“address”:“Adddr”}],“status”:“status”}

我知道可以执行
POST/nested'{“parent”:“/link/to/parent”}
。但若这是一种通过父对象获取嵌套对象的方法,为什么我不能以这种方式发布/放置/修补它们呢?我检查过了,它是RESTfull吗?似乎是。

spring数据rest文档中有一节告诉您在这个资源上可以做什么。创建一个新的子项并将其关联是不可能的

我不知道这是为什么


获得这种行为的唯一方法(据我所知)是实现一个自定义控制器,它可以为您实现这种行为。(请确保不要在自定义控制器的类级别上使用
@RequestMapping
注释,以免覆盖比您希望的更多的spring数据rest功能)

谢谢!是的,可能我需要为此创建控制器。