Hibernate 3.1.3, MySQL 4.0.x, MySQL JDBC Driver 3.1.13
The exception during a
hsession.get() is:
Caused by: java.sql.SQLException: '128' in column '9' is outside valid range for the datatype TINYINT.
My table datatype is "TINYINT UNSIGNED" which on MySQL has a range of 0 to 255. It is true that if my datatype did not have the UNSIGNED part it would have a range of -128 to 127, making 128 outside the valid range.
My POJO looks like this:
Code:
public class Foobar {
private short dataValue;
public void setDataValue(short dataValue) {
if(dataValue < 0 || dataValue > 255)
return;
this.dataValue = dataValue;
}
public short getDataValue() {
return this.dataValue;
}
}
The mapping looks like this:
<property name="dataValue" type="short" column="data_value" />
I have upgraded both Hibernate form 3.1.2 to 3.1.3 recently and the MySQL driver, since this code was last confirmed working.
Are SQLException's only ever generated from JDBC drivers ? If so this problem is with my JDBC driver ?
I am expecting Hibernate to call the JDBC getShort() function to get the value for the TINYINT UNSIGNED value.