我有一个带有端点的Spring Boot / Data Api,用于删除记录。当我发送请求时,Hibernate日志如下:2018-04-29 18:05:04.920 DEBUG 8928 --- [nio-8080-exec-2] org.hibernate.SQL : select max(id) from registration
2018-04-29 18:05:04.950 DEBUG 8928 --- [nio-8080-exec-2] org.hibernate.SQL : insert into registration (e_id, first_name, last_name, tech, id) values (?, ?, ?, ?, ?)
2018-04-29 18:05:04.953 TRACE 8928 --- [nio-8080-exec-2] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [VARCHAR] - [tbc328]
2018-04-29 18:05:04.953 TRACE 8928 --- [nio-8080-exec-2] o.h.type.descriptor.sql.BasicBinder : binding parameter [2] as [VARCHAR] - [Fon]
2018-04-29 18:05:04.953 TRACE 8928 --- [nio-8080-exec-2] o.h.type.descriptor.sql.BasicBinder : binding parameter [3] as [VARCHAR] - [Bom]
2018-04-29 18:05:04.953 TRACE 8928 --- [nio-8080-exec-2] o.h.type.descriptor.sql.BasicBinder : binding parameter [4] as [VARCHAR] - [Java]
2018-04-29 18:05:04.953 TRACE 8928 --- [nio-8080-exec-2] o.h.type.descriptor.sql.BasicBinder : binding parameter [5] as [INTEGER] - [29]
2018-04-29 18:05:04.960 DEBUG 8928 --- [nio-8080-exec-2] org.hibernate.SQL : delete from registration where id=?
2018-04-29 18:05:04.960 TRACE 8928 --- [nio-8080-exec-2] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [INTEGER] - [29]
它会在同一记录之后发出insert
然后是delete
吗?我要删除的记录仍然有200个http代码?
发帖人详情。
URL:localhost:8080/delete
请求正文:{
"firstName": "Fon",
"lastName": "Bom",
"eId": "tbc328",
"tech": "Java"
}
由于
答案 0 :(得分:0)
在创建新记录并将其传递给删除时。 Hibernate检查对象是否已经持久化。如果没有,首先它将尝试持久化对象,然后它将删除它。
与您的情况一样,对象标识符id
为空。
有关详情,请点击此处hibernate delete event