5 Replies Latest reply on May 27, 2002 12:22 AM by Shailesh Dangi

    invalid column type bigdecimal oracle

    Tim Fox Master

      I'm having some problems saving an entity with a field type of BigDecimal.
      Loading is fine.

      Here's the info:
      Version: 3.0 RC2
      Database: Oracle 8.1.7
      Java type: java.math.BigDecimal
      DB Column type: NUMBER(38,2)

      Extract from mapping file:


      <java-type>java.math.BigDecimal</java-type>
      <jdbc-type>DECIMAL</jdbc-type>
      <sql-type>NUMBER(38,2)</sql-type>


      Exception is:

      Invalid column type
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.setArgumentParameters(JDBCAbstractCMPFieldBridge.java:289)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.setInstanceParameters(JDBCAbstractCMPFieldBridge.java:262)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.insertEntity(JDBCCreateEntityCommand.java:192)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.execute(JDBCCreateEntityCommand.java:131)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:444)
      at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:253)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:231)
      at org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:579)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1116)
      at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:73)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:230)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:176)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:134)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:79)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:44)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:98)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:167)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:104)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:109)
      at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invokeHome(BaseLocalContainerInvoker.java:227)
      at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110)
      at $Proxy385.create(Unknown Source)
      at com.blueheath.mercury.server.ejb.test.TestBean.test1(TestBean.java:123)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:664)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:147)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:96)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:167)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:129)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
      at org.jboss.ejb.Container.invoke(Container.java:706)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:364)
      at java.lang.reflect.Method.invoke(Native Method)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
      at sun.rmi.transport.Transport$1.run(Transport.java:142)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:139)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:443)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:643)
      at java.lang.Thread.run(Thread.java:484)
      java.sql.SQLException: Invalid column type
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
      at oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:4560)
      at oracle.jdbc.driver.OraclePreparedStatement.setNull(OraclePreparedStatement.java:869)
      at org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement.setNull(LocalPreparedStatement.java:343)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.setParameter(JDBCUtil.java:144)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.setArgumentParameters(JDBCAbstractCMPFieldBridge.java:283)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.setInstanceParameters(JDBCAbstractCMPFieldBridge.java:262)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.insertEntity(JDBCCreateEntityCommand.java:192)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.execute(JDBCCreateEntityCommand.java:131)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:444)
      at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:253)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:231)
      at org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:579)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1116)
      at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:73)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:230)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:176)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:134)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:79)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:44)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:98)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:167)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:104)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:109)
      at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invokeHome(BaseLocalContainerInvoker.java:227)
      at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110)
      at $Proxy385.create(Unknown Source)
      at com.blueheath.mercury.server.ejb.test.TestBean.test1(TestBean.java:123)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:664)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:147)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:96)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:167)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:129)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
      at org.jboss.ejb.Container.invoke(Container.java:706)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:364)
      at java.lang.reflect.Method.invoke(Native Method)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
      at sun.rmi.transport.Transport$1.run(Transport.java:142)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:139)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:443)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:643)
      at java.lang.Thread.run(Thread.java:484)
      2002-05-15 12:15:31,887 INFO [STDOUT] Caught create exception: Could not create entity:javax.ejb.EJBException: Internal error setting parameters for field bdField
      Embedded Exception
      Invalid column type

        • 1. Re: invalid column type bigdecimal oracle
          Dain Sundstrom Master

          This is the important part of the stack trace:

          java.sql.SQLException: Invalid column type
          at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
          at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
          at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
          at oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:4560)
          at oracle.jdbc.driver.OraclePreparedStatement.setNull(OraclePreparedStatement.java:869)
          at org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement.setNull(LocalPreparedStatement.java:343)
          at org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.setParameter(JDBCUtil.java:144)
          at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.setArgumentParameters

          As you can see, JBossCMP is simply setting this field to null (setNull). Did you mark this field as not-null?

          • 2. Re: invalid column type bigdecimal oracle
            Tim Fox Master

            You're right - I had a null value and the column was not null in the database.

            However, when I now specify a value, I get another exception: "inconsistent datatypes" (see below).

            Looking into the code and looking at the server.log, it seems that the JDBCUtil class is trying to set (on the preparedstatement) my bigdecimal field as JAVA_OBJECT - even though I have explicitly mapped it as DECIMAL.

            Here's the excerpt from the log file:
            2002-05-15 17:45:42,779 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.TesterEJB.bdField] Set parameter: index=4, jdbcType=JAVA_OBJECT, value=8888.88

            Moreover, if a specify a nonsense or non-existent type-mapping in the config then I don't get a warning/error message, and exactly the same happens.

            I'm starting to think that jboss isn't picking up my type-mapping for some reason, and mapping java.math.BigDecimal to JAVA_OBJECT since it doesn't now what to do with it (??? Just a guess).

            I did try putting my type mapping in jbosscmp-jdbc.xml, and now have moved it to standardjbosscmp-jdbc.xml.

            Is that where it should go?

            Anyway, I'm kind of confused since whatever I seem to do to the type-mapping doesn't seem to make a difference.

            • 3. Re: invalid column type bigdecimal oracle
              Dain Sundstrom Master

              type-mappings do not support overriding. I suggest that you just override that mapping for the specific field, but you could create a new private mapping. You could modify the standardjbosscmp-jdbc.xml file, but I don't recomend that, as it may change from version to version.

              • 4. Re: invalid column type bigdecimal oracle
                Tim Fox Master

                Dain-

                I have solved the problem here.

                My suspicion was right in that it was not picking up the correct mapping file.

                Basically I was using the <type-mapping> tag inside the tag in jbosscmp-jdbc.xml to specify which mapping to use.

                This I copied from the example in the documents package.

                Looking at the dtd it appears the <type-mapping> tag no longer means anything inside the tag and we should use the <datasource-mapping> tag instead.

                Anyway, when I replace one for the other, it all works and my bigdecimal is persisted ok.

                I guess we need to update the example that comes with the docs?

                SO, as I say BigDecimal now works but Character unfortunately doesn't.

                • 5. Re: invalid column type bigdecimal oracle
                  Shailesh Dangi Newbie

                  I experienced a similar problem on one of the finder methods while upgrading JBoss from 2.4 to 3.0RC3.
                  Haven't figured it out yet. findByPK works fine and shows jdbcType as DECIMAL. However, on the finder methods it using jdbcType as JAVA_OBJECT. I am using jaws.xml to define the mapping and finder methods.

                  Please let me know if something has changed as I have revisited JBoss after about 5-6 weeks.

                  Thanks