Spring boot 更新hibernate onetomany中的联接表id不工作
我是spring boot新手,我正在尝试在任务表中实现更新cid,但它不起作用Spring boot 更新hibernate onetomany中的联接表id不工作,spring-boot,hibernate,jpa,Spring Boot,Hibernate,Jpa,我是spring boot新手,我正在尝试在任务表中实现更新cid,但它不起作用 @Entity @Table(name="kanban_col") public class kanban_columns { @Id @GeneratedValue(generator="system-uuid") @GenericGenerator(name="system-uuid", strategy = "uui
@Entity
@Table(name="kanban_col")
public class kanban_columns {
@Id
@GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid", strategy = "uuid")
private String id;
@Column(name="col_name")
private String colName;
@Column(name="kbid")
private String boardId;
@OneToMany(mappedBy = "kanban_col_id",cascade = CascadeType.PERSIST,orphanRemoval = true,fetch=FetchType.LAZY)
private List<Tasks> tasks;
Getter and setters....
public void updatetasks(Tasks tasks){
tasks.setKanban_col_id(this);
}
}
服务
@Transactional
public kanban_columns UpdateTaskEntity(final kanban_columns source) {
final kanban_columns destination = repository.findTaskById(source.getId());
System.out.println(destination);
updatedTask(source, destination);
repository.save(destination);
return destination;
}
public void updatedTask(final kanban_columns source, final kanban_columns destination) {
destination.updatetasks((Tasks) source.getTasks());
}
存储库
@Query("select kc from kanban_columns kc,Tasks t where t.id=:id")
kanban_columns findTaskById(@Param("id") String id);
例外情况
JSON parse error: Cannot construct instance of `net.guides.springboot.loginregistrationspringbootauthjsp.model.kanban_columns` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('ff80808174f95b8c0174f95ba1e30001'); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `net.guides.springboot.loginregistrationspringbootauthjsp.model.kanban_columns` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('ff80808174f95b8c0174f95ba1e30001')
at [Source: (PushbackInputStream); line: 5, column: 22] (through reference chain: net.guides.springboot.loginregistrationspringbootauthjsp.model.kanban_columns["tasks"]->java.util.ArrayList[0]->net.guides.springboot.loginregistrationspringbootauthjsp.model.Tasks["kanban_col_id"]
JSON
我想更新使用@OneToMany和@ManyToOne映射连接的列cid(看板列id)。
我获取了id为的任务,但我尝试更新colcid,但它显示异常
任何人,请帮助我实现这一点
谢谢你 看看这个:
JSON parse error: Cannot construct instance of `net.guides.springboot.loginregistrationspringbootauthjsp.model.kanban_columns` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('ff80808174f95b8c0174f95ba1e30001'); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `net.guides.springboot.loginregistrationspringbootauthjsp.model.kanban_columns` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('ff80808174f95b8c0174f95ba1e30001')
at [Source: (PushbackInputStream); line: 5, column: 22] (through reference chain: net.guides.springboot.loginregistrationspringbootauthjsp.model.kanban_columns["tasks"]->java.util.ArrayList[0]->net.guides.springboot.loginregistrationspringbootauthjsp.model.Tasks["kanban_col_id"]
{
"id":"ff80808174f95b8c0174f95ba1e30001",
"tasks":[{
"kanban_col_id":"ff80808174f95b8c0174f95ba1e30002"
}
]
}