OwlFocus

hibernate outside valid range for the datatype smallint

hibernate 使用sql查询时,smallint类型字段出现长度超过。因为smallint使用的是无符号类型unsigned,导致长度超过。

错误

hibernate ‘65535.0’ in column ‘12’ is outside valid range for the datatype SMALLINT.

解决

使用函数将字段类型数据进行转化,如下:

CAST(column AS signed)