I have a MySQL v 4.0.16 table with a field of type tinyint(3) unsigned.
i.e. values of 255 are valid and present in the table.
Middlegen-Hibernate-r4 generates the following in the .hbm.xml file:
<property
name="privacyAgreement"
type="byte"
column="privacy_agreement"
not-null="true"
length="3"
/>
Then, of course, hibernate-extensions-2.1 generates this POJO:
/** persistent field */
private byte privacyAgreement;
and when I do query.list( "from Custoner where..." ); it fails with:
Hibernate: select customer0_.privacy_agreement as privacy29_ from customer customer0_ where (email='luvin_newfoundglory@hotmail.com' )
11:01:02,206 WARN JDBCExceptionReporter:38 - SQL Error: 0, SQLState: S1009
11:01:02,206 ERROR JDBCExceptionReporter:46 - Value '255' is out of range [-127,127]
11:01:02,287 WARN JDBCExceptionReporter:38 - SQL Error: 0, SQLState: S1009
11:01:02,287 ERROR JDBCExceptionReporter:46 - Value '255' is out of range [-127,127]
11:01:02,297 ERROR JDBCExceptionReporter:38 - Could not execute query
java.sql.SQLException: Value '255' is out of range [-127,127]
at com.mysql.jdbc.ResultSet.getByte(ResultSet.java:687)
at com.mysql.jdbc.ResultSet.getByte(ResultSet.java:724)
at com.mchange.v2.sql.filter.FilterResultSet.getByte(FilterResultSet.java:358)
at net.sf.hibernate.type.ByteType.get(ByteType.java:18)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
at net.sf.hibernate.type.AbstractType.hydrate(AbstractType.java:66)
at net.sf.hibernate.loader.Loader.hydrate(Loader.java:611)
at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:552)
at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:511)
at net.sf.hibernate.loader.Loader.getRow(Loader.java:426)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:209)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1536)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at com.umusic.ecrm.db.Connect.getList(Connect.java:372)
at Main.main(Main.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
11:01:02,297 ERROR Connect:374 - Hibernate ExceptionCould not execute query
java.lang.RuntimeException: net.sf.hibernate.JDBCException: Could not execute query
at com.umusic.ecrm.db.Connect.getList(Connect.java:375)
at Main.main(Main.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
Caused by: net.sf.hibernate.JDBCException: Could not execute query
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1539)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at com.umusic.ecrm.db.Connect.getList(Connect.java:372)
... 6 more
Caused by: java.sql.SQLException: Value '255' is out of range [-127,127]
at com.mysql.jdbc.ResultSet.getByte(ResultSet.java:687)
at com.mysql.jdbc.ResultSet.getByte(ResultSet.java:724)
at com.mchange.v2.sql.filter.FilterResultSet.getByte(FilterResultSet.java:358)
at net.sf.hibernate.type.ByteType.get(ByteType.java:18)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
at net.sf.hibernate.type.AbstractType.hydrate(AbstractType.java:66)
at net.sf.hibernate.loader.Loader.hydrate(Loader.java:611)
at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:552)
at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:511)
at net.sf.hibernate.loader.Loader.getRow(Loader.java:426)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:209)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1536)
... 8 more
_______________________________________________________
Of course, I could change the type in the .hbm.xml file manually, but I just wanted to know if this is a bug in Middlegen and if there is a way to set it up so it creates a type that can hold a value of 255?
Thanks a lot--
Egor
|