-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Middlegen generates byte for unsigned tinyint(3)
PostPosted: Wed May 12, 2004 5:32 pm 
Newbie

Joined: Wed May 12, 2004 5:09 pm
Posts: 17
Location: Los Angeles
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 12, 2004 6:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The hibernate plugin has a TypeMapping plugin feature (a plugin for the plugin) you can use the standard one I supply or create your own to generate the types the way you want them to be created. The CVS version has a number of changes to the standard mapper. It is not used by default. See the Middlegen page on the wiki for more information.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.