Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0.5
Mapping documents:
3.0
Code between sessionFactory.openSession() and session.close():
String query = "select cast(ord.orderNo as integer) as cst_number from Order ord";
int result = ((Integer)(session.createQuery(query).iterate().next())).intValue();
System.out.println("result="+result);
Full stack trace of any exception that occurs:
java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.MethodNode
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'cast' {originalText=cast}
\-[EXPR_LIST] SqlNode: 'exprList'
+-[DOT] DotNode: 'order0_.ORDER_NO' {propertyName=orderNo,dereferenceType=4,propertyPath=orderNo,path=ord.orderNo,tableAlias=order0_,className=com.bsteel.baobao.eb.order.model.Order,classAlias=ord}
| +-[ALIAS_REF] IdentNode: 'order0_.ID' {alias=ord, className=com.test.model.Order, tableAlias=order0_}
| \-[IDENT] IdentNode: 'orderNo' {originalText=orderNo}
\-[IDENT] IdentNode: 'integer' {originalText=integer}
at org.hibernate.hql.ast.SelectClause.initializeExplicitSelectClause(SelectClause.java:136)
at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:440)
at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:351)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.afterQuery(HqlSqlBaseWalker.java:126)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:471)
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.iterate(SessionImpl.java:920)
at org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:41)
at com.bsteel.baobao.eb.product.dao.impl.ProductOnlineDaoImplSt$1.doInHibernate(ProductOnlineDaoImplSt.java:72)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:311)
at org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:292)
at com.bsteel.baobao.eb.product.dao.impl.ProductOnlineDaoImplSt.queryByProductNo(ProductOnlineDaoImplSt.java:68)
at com.bsteel.baobao.eb.product.dao.ProductOnlineDaoImplTest.testSave(ProductOnlineDaoImplTest.java:45)
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 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:
oracle 9i
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
My Issue:
I trace the org.hibernate.dialect.function.CastFunction
I got it
public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
//TODO: pass in the arguments here...
return null; //it needs to be the argument type
}
this return value cause the " No data type for node" exception.
When this feature will be implemented?
How can I use HQL function to implement ORACLE to_number?