update weight_note_receipt set pledge_id =:pledge where wn_id in (:wns)
wns是包含多个wn_id的字符串,如下所示:
222,226,228,251,256,262,263,264,265,266,267,272,281,286,294,296,299,301,302,303,306,307,330,332,333,337,338,339,341,368,371,376,377,378,379,380,381,385,391,397,423,424,443,452,454,461,462,463,464,490,503,504,521,525,528,529,530,532,533,549,554,560,561,564,565,566,567,569,570,595,598,600,603,605,606,607,644,646,649,653,661,662,663,667,669,678,683,752,1039,1075,258,259,260,261,268,269,270,287,304,305,308,325,334,604,643,647,648,659,660,664,665,666,704,709,753,754,757,758,809,834,846,861,872,879,882,911,913,916,919,920,164
当我更新(使用query.executeUpdate())时,它会抛出以下错误:
Request processing Failed; nested exception is org.hibernate.exception.DataException: could not execute native bulk
manipulation query] with root cause
com.MysqL.jdbc.MysqLDataTruncation: Data truncation: Truncated incorrect DOUBLE value:
‘222,’
是因为输入字符串太长了吗?
这就是为什么你不能为以下查询准备好的语句:
>从myTable订单中选择*?
>选择id,f1,?来自myTable
> select * from?.
因为为每个参数赋值会更改查询执行路径(请记住,预处理语句的查询会被解析一次并产生单个执行路径).
相同的规则适用于Hibernate查询解析器,您不应为参数分配更改查询结构的值.
将值为1,2,3的字符串分配给SHOULD-TO-BE-A-NUMBER参数是相同的,实际上第一个查询将被翻译为与更新weight_note_receipt相同的set pledge_id =:pledge其中wn_id =: wns但第二个将被翻译为update weight_note_receipt set pledge_id =:pledge where(wn_id =:x1或wn_id =:x2或wn_id =:x3),显然是具有不同执行路径的不同查询.
所以即使Hibernate没有抛出异常,你的数据库也会如此.