Hello,
I'm currently trying to map a NUMBER(10) field across to my domain object. I've tried mapping to a long, and to a BigDecimal, but I keep getting a sql error, invalid number (see below).
Basically the column holds an account type number, so no decimal places are required.
Versions: Oracle, 10.103, Hibernate 3.0
If anyone has achieved this and could supply me with any tips it would be most appreciated.
James Heffernan
Hibernate version:
Hibernate 3.0
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
[DEBUG] HqlSqlBaseWalker - -query() >> end, level = 1
[DEBUG] AST - ---- SQL AST ---
\-[SELECT] QueryNode: 'SELECT' querySpaces (lowusercustomers)
+-[SELECT_CLAUSE] SelectClause: '{derived select clause}'
| +-[SELECT_EXPR] SelectExpressionImpl: 'lowusagecu0_.luid as luid' {FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=lucustomer,role=null,tableName=lowusercustomers,tableAlias=lowusagecu0_,colums={,className=nz.co.contactenergy.ivr.data.LowUsageCustomer}}}
| \-[SQL_TOKEN] SqlFragment: 'lowusagecu0_.ConsumerNumber as Consumer2_4_, lowusagecu0_.ReadFromDate as ReadFrom3_4_, lowusagecu0_.ReadToDate as ReadToDate4_, lowusagecu0_.NumberOfDays as NumberOf5_4_, lowusagecu0_.TotalUnits as TotalUnits4_, lowusagecu0_.AnnualConsumption as AnnualCo7_4_, lowusagecu0_.Confirmed as Confirmed4_, lowusagecu0_.Accessed as Accessed4_, lowusagecu0_.Extracted as Extracted4_, lowusagecu0_.Cancelled as Cancelled4_'
+-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[lucustomer], fromElementByTableAlias=[lowusagecu0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
| \-[FROM_FRAGMENT] FromElement: 'lowusercustomers lowusagecu0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=lucustomer,role=null,tableName=lowusercustomers,tableAlias=lowusagecu0_,colums={,className=nz.co.contactenergy.ivr.data.LowUsageCustomer}}
\-[WHERE] SqlNode: 'where'
\-[EQ] SqlNode: '='
+-[DOT] DotNode: 'lowusagecu0_.ConsumerNumber' {propertyName=accountnumber,dereferenceType=4,propertyPath=accountnumber,path=lucustomer.accountnumber,tableAlias=lowusagecu0_,className=nz.co.contactenergy.ivr.data.LowUsageCustomer,classAlias=lucustomer}
| +-[ALIAS_REF] IdentNode: 'lowusagecu0_.luid' {alias=lucustomer, className=nz.co.contactenergy.ivr.data.LowUsageCustomer, tableAlias=lowusagecu0_}
| \-[IDENT] IdentNode: 'accountnumber' {originalText=accountnumber}
\-[PARAM] SqlNode: '?'
[DEBUG] ErrorCounter - -throwQueryException() : no errors
[DEBUG] QueryTranslatorImpl - -HQL: from nz.co.contactenergy.ivr.data.LowUsageCustomer as lucustomer where lucustomer.accountnumber = ?
[DEBUG] QueryTranslatorImpl - -SQL: select lowusagecu0_.luid as luid, lowusagecu0_.ConsumerNumber as Consumer2_4_, lowusagecu0_.ReadFromDate as ReadFrom3_4_, lowusagecu0_.ReadToDate as ReadToDate4_, lowusagecu0_.NumberOfDays as NumberOf5_4_, lowusagecu0_.TotalUnits as TotalUnits4_, lowusagecu0_.AnnualConsumption as AnnualCo7_4_, lowusagecu0_.Confirmed as Confirmed4_, lowusagecu0_.Accessed as Accessed4_, lowusagecu0_.Extracted as Extracted4_, lowusagecu0_.Cancelled as Cancelled4_ from lowusercustomers lowusagecu0_ where lowusagecu0_.ConsumerNumber=?
[DEBUG] ErrorCounter - -throwQueryException() : no errors
[DEBUG] AbstractBatcher - -about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
[DEBUG] ConnectionManager - -opening JDBC connection
[DEBUG] SQL - -select lowusagecu0_.luid as luid, lowusagecu0_.ConsumerNumber as Consumer2_4_, lowusagecu0_.ReadFromDate as ReadFrom3_4_, lowusagecu0_.ReadToDate as ReadToDate4_, lowusagecu0_.NumberOfDays as NumberOf5_4_, lowusagecu0_.TotalUnits as TotalUnits4_, lowusagecu0_.AnnualConsumption as AnnualCo7_4_, lowusagecu0_.Confirmed as Confirmed4_, lowusagecu0_.Accessed as Accessed4_, lowusagecu0_.Extracted as Extracted4_, lowusagecu0_.Cancelled as Cancelled4_ from lowusercustomers lowusagecu0_ where lowusagecu0_.ConsumerNumber=?
[DEBUG] AbstractBatcher - -about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
[DEBUG] JDBCExceptionReporter - -could not execute query [select lowusagecu0_.luid as luid, lowusagecu0_.ConsumerNumber as Consumer2_4_, lowusagecu0_.ReadFromDate as ReadFrom3_4_, lowusagecu0_.ReadToDate as ReadToDate4_, lowusagecu0_.NumberOfDays as NumberOf5_4_, lowusagecu0_.TotalUnits as TotalUnits4_, lowusagecu0_.AnnualConsumption as AnnualCo7_4_, lowusagecu0_.Confirmed as Confirmed4_, lowusagecu0_.Accessed as Accessed4_, lowusagecu0_.Extracted as Extracted4_, lowusagecu0_.Cancelled as Cancelled4_ from lowusercustomers lowusagecu0_ where lowusagecu0_.ConsumerNumber=?] <java.sql.SQLException: ORA-01722: invalid number
>java.sql.SQLException: ORA-01722: invalid number
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:830)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2391)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2672)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:527)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)
at org.hibernate.loader.Loader.doQuery(Loader.java:391)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:751)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:312)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:742)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:738)
at nz.co.contactenergy.ivr.data.oracle.HibernateLowUsageCustomerDao.getByAccountnumber(Unknown Source)
at nz.co.contactenergy.ivr.data.oracle.HibernateOracleDataChannel.getCustomer(Unknown Source)
at nz.co.contactenergy.ivr.data.oracle.HibernateOracleDataChannel.buildDataSet(Unknown Source)
at nz.co.contactenergy.ivr.data.oracle.HibernateOracleDataChannel.buildLowUserCustomer(Unknown Source)
at nz.co.contactenergy.ivr.data.oracle.HibernateOracleDataChannel.invokeTransaction(Unknown Source)
at nz.co.contactenergy.ivr.data.DefaultDataBuilder.getDCData(Unknown Source)
at nz.co.contactenergy.ivr.data.DefaultDataBuilder.getData(Unknown Source)
at nz.co.contactenergy.ivr.DefaultModelGenerator.buildData(Unknown Source)
at nz.co.contactenergy.ivr.DefaultModelGenerator.getModel(Unknown Source)
at nz.co.contactenergy.ivr.ControllerServlet.setupModel(Unknown Source)
at nz.co.contactenergy.ivr.ControllerServlet.controller(Unknown Source)
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 org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:351)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:305)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:128)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:684)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:625)
at org.springframework.web.servlet.FrameworkServlet.serviceWrapper(FrameworkServlet.java:386)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:346)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
[WARN] JDBCExceptionReporter - -SQL Error: 1722, SQLState: 42000
[ERROR] JDBCExceptionReporter - -ORA-01722: invalid number
[DEBUG] SQLErrorCodeSQLExceptionTranslator - -Translating SQLException with SQLState '42000' and errorCode '1722' and message [ORA-01722: invalid number
]; SQL was [select lowusagecu0_.luid as luid, lowusagecu0_.ConsumerNumber as Consumer2_4_, lowusagecu0_.ReadFromDate as ReadFrom3_4_, lowusagecu0_.ReadToDate as ReadToDate4_, lowusagecu0_.NumberOfDays as NumberOf5_4_, lowusagecu0_.TotalUnits as TotalUnits4_, lowusagecu0_.AnnualConsumption as AnnualCo7_4_, lowusagecu0_.Confirmed as Confirmed4_, lowusagecu0_.Accessed as Accessed4_, lowusagecu0_.Extracted as Extracted4_, lowusagecu0_.Cancelled as Cancelled4_ from lowusercustomers lowusagecu0_ where lowusagecu0_.ConsumerNumber=?] for task [Hibernate operation: could not execute query]
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
|