Hibernate version:
3.1 (no RC)
Relevant portion of mapping document:
<property
name="flight_level"
formula="fltLvl * 100"
type="java.lang.Integer"
column="fltLvl"
not-null="true"
length="5" >
<meta attribute="field-description">
@hibernate.property
column="fltLvl"
length="5"
not-null="true"
</meta>
</property>
Code between sessionFactory.openSession() and session.close():
Code:
Criteria crit = session.createCriteria( MyClass.class );
Criterion between = Expression.between( "flight_level", new Long( 40000 ), new Long( 50000 ) );
crit.add( between );
List list = crit.list();
Full stack trace of any exception that occurs:org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2153)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1492)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:298)
at Test.test(Test.java:0)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:31)
Caused by: java.sql.SQLException: No value specified for parameter 1
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:1257)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:1205)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:969)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2150)
... 24 more
Name and version of the database you are using:MySQL 3.23.49
The generated SQL (show_sql=true):None. This fails before SQL is generated.
Is this expected behavior? If I substitute new Integer() for my new Long() code, this code works just fine. With Longs, it fails. The HQL version works fine:
Code:
String hql = "from MyClass where flight_level between "+40000L+" and "+50000L;
Query q = session.createQuery( hql );
List list = q.list();
This doesn't strike me as expected behavior. Am I missing something?
Thanks