【问题标题】:Spring Rest Hibernate Update List with PUT method使用 PUT 方法的 Spring Rest Hibernate 更新列表
【发布时间】:2016-09-25 20:09:00
【问题描述】:

我想用休息服务更新列表,但抛出了 InvalidDataAccessApiUsageException:

Parameter value element [Sharing{uuid=af777b47-3dfc...updated=2016-05-04T10:37:29.000Z}]  did not match expected type [java.util.UUID (n/a)]

控制器:

@RequestMapping(value = "/updateChecked", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
public int update(@RequestBody SharingList shares){
    return this.sharingService.updateChecked(shares);
}

服务:

public int updateChecked(SharingList shares) {
        int updated = sharingDao.setCheckedSharingFor(shares);
        return updated;
    }

道:

@Modifying
@Query("UPDATE Sharing s SET s.checked=1 WHERE uuid in :shares")
int setCheckedSharingFor(@Param("shares") SharingList shares);

分享列表:

public class SharingList extends ArrayList<Sharing> {

}

请问有什么问题吗?

【问题讨论】:

    标签: spring hibernate rest


    【解决方案1】:

    这里有答案

    Sharing{uuid=af777b47-3dfc...updated=2016-05-04T10:37:29.000Z}]  
    did not match expected type [java.util.UUID (n/a)]
    

    Hibernate 没有人工智能来理解它应该从Sharing 获取uuid

    对于这个查询

    @Query("UPDATE Sharing s SET s.checked=1 WHERE uuid in :shares")
    

    您应该提供UUID 的集合作为shares 参数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-21
      • 2021-01-24
      • 2017-12-25
      • 1970-01-01
      • 2021-03-01
      • 2019-12-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多