Hibernate version:
3
Quote:
This problem don't exist in Hibernate 2.
Java Bean:
Code:
package org.hibernate.bug1;
public class BaBu1_Record
{
private int m_key;
private double m_a;
/**
* @return the value A
*/
public double getA()
{
return m_a;
}
/**
* @param a the Value A
*/
public void setA(double a)
{
m_a = a;
}
/**
* @return the primary key
*/
public int getKey()
{
return m_key;
}
/**
* @param m_key set the primary key
*/
private void setKey(int key)
{
m_key = key;
}
}
Mapping documents:BaBu1_Record.hbm.xml:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.hibernate.bug1">
<class name="BaBu1_Record">
<id name="key"><generator class="native" /></id>
<property name="a" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
final String hsqlStatement = "from BaBu1_Record r where abs(r.a - :value) < 0.001";
Query query = session.createQuery(hsqlStatement);
query.setDouble("value", 1.0d);
query.list();
Full stack trace of any exception that occurs:Code:
java.lang.ClassCastException
at org.hibernate.hql.ast.ArithmeticNode.getDataType(ArithmeticNode.java:13)
at org.hibernate.hql.ast.SessionFactoryHelper.findFunctionReturnType(SessionFactoryHelper.java:188)
at org.hibernate.hql.ast.MethodNode.dialectFunction(MethodNode.java:55)
at org.hibernate.hql.ast.MethodNode.resolve(MethodNode.java:43)
at org.hibernate.hql.ast.HqlSqlWalker.processFunction(HqlSqlWalker.java:538)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.functionCall(HqlSqlBaseWalker.java:2045)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:933)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:3713)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3240)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1405)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:599)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:404)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.hibernate.bug1.BaBu1_BugTest_tc.testBug1(BaBu1_BugTest_tc.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:474)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:194)
Name and version of the database you are using:
HSQLDB and Oracle 9.2.0.6. The problem is a bug in Hibernate and so
independant of the used database.
The generated SQL (show_sql=true):
There is no generated SQL.
Can anybody confirm this Hibernate bug! Thanks!