6 Replies Latest reply on Aug 20, 2002 9:55 AM by tinnes

    BigDecimal Issue

    tinnes

      I am having problems trying to persist a BigDecimal into PostgreSQL V 7.2. I thought the problem might be the type mapping so I added a type mapping Entry in the PostgreSQL 7.2 section of the standardjbosscmp-jdbc.xml file as follows:


      <java-type>java.math.BigDecimal</java-type>
      <jdbc-type>DECIMAL</jdbc-type>
      <sql-type>DECIMAL</sql-type>


      the column in question is defined as DECIMAL(20). It is not the primary key.

      The stack trace is as follows:
      MicroKernel) [3.0.0 Date:200205311035] Started in 0m:49s:518ms
      2002-07-09 19:29:02,248 DEBUG [org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy] Resized cache for bean TPatient: old capacity = 1000000, new capacity = 50
      2002-07-09 19:29:29,647 DEBUG [org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy] Resized cache for bean TFacilityDepartment: old capacity = 1000000, new capacity = 50
      2002-07-09 19:29:42,857 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCFindByPrimaryKeyQuery.TKeySequence.findByPrimaryKey] Executing SQL: SELECT sequence_name FROM t_key_sequence WHERE sequence_name=?
      2002-07-09 19:29:42,948 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.TKeySequence] Create: pk=Greg
      2002-07-09 19:29:42,948 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.TKeySequence] Executing SQL: SELECT COUNT(*) FROM t_key_sequence WHERE sequence_name=?
      2002-07-09 19:29:42,952 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.TKeySequence] Executing SQL: INSERT INTO t_key_sequence (sequence_name, description_1, description_2, start_sequence, next_sequence, max_sequence, block_size, increment_by, rollover_flag, created_date, updated_date, updated_user) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
      2002-07-09 19:29:43,146 ERROR [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.TKeySequence] Could not create entity
      java.sql.SQLException: ERROR: Bad numeric input format '\254\355\000\005sr\000\031java.rmi.MarshalledObject|\275\036\227\355c\374>\002\000\003I\000\004hash[\000\010locBytest\000\002[B[\000\010objBytesq\000~\000\001xpa\343g\305ur\000\002[B\254\363\027\370\006\010T\340\002\000\000xp\000\000\000)\254\355\000\005t\000\027http://CR283020-A:8083/q\000~\000\000q\000~\000\000puq\000~\000\003\000\000\001!\254\355\000\005sr\000\024java.math.BigDecimalT\307\025W\371\201(O\002\000\002I\000\005scaleL\000\006intValt\000\026Ljava/math/BigInteger;xr\000\020java.lang.Number\206\254\225\035\013\224\340\213\002\000\000xp\000\000\000\000sr\000\024java.math.BigInteger\214\374\237\037\251;\373\035\002\000\006I\000\010bitCountI\000\011bitLengthI\000\023firstNonzeroByteNumI\000\014lowestSetBitI\000\006signum[\000\011magnitudet\000\002[Bxq\000~\000\002\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\376\000\000\000\001ur\000\002[B\254\363\027\370\006\010T\340\002\000\000xp\000\000\000\001\001'

      at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:94)
      at org.postgresql.Connection.ExecSQL(Connection.java:398)
      at org.postgresql.jdbc2.Statement.execute(Statement.java:130)
      at org.postgresql.jdbc2.Statement.executeUpdate(Statement.java:73)
      at org.postgresql.jdbc2.PreparedStatement.executeUpdate(PreparedStatement.java:113)
      at org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement.executeUpdate(LocalPreparedStatement.java:308)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.insertEntity(JDBCCreateEntityCommand.java:196)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.execute(JDBCCreateEntityCommand.java:131)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:450)
      at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:253)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:270)
      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:257)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:215)
      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 $Proxy35.create(Unknown Source)
      at urms.util.server.database.pkgenerator.session.keysequence.KeySequenceSessionBean.getNextSequenceBlock(KeySequenceSessionBean.java:65)
      at urms.util.server.database.pkgenerator.session.keysequence.KeySequenceSessionBean.getNextSequenceNumber(KeySequenceSessionBean.java:138)
      at urms.util.server.database.pkgenerator.session.keysequence.KeySequenceSessionBean.getNextSequence(KeySequenceSessionBean.java:125)
      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:186)
      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:705)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:362)
      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:152)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:148)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:706)
      at java.lang.Thread.run(Thread.java:484)
      2002-07-09 19:29:43,166 ERROR [STDERR] javax.ejb.CreateException: Could not create entity:java.sql.SQLException: ERROR: Bad numeric input format '\254\355\000\005sr\000\031java.rmi.MarshalledObject|\275\036\227\355c\374>\002\000\003I\000\004hash[\000\010locBytest\000\002[B[\000\010objBytesq\000~\000\001xpa\343g\305ur\000\002[B\254\363\027\370\006\010T\340\002\000\000xp\000\000\000)\254\355\000\005t\000\027http://CR283020-A:8083/q\000~\000\000q\000~\000\000puq\000~\000\003\000\000\001!\254\355\000\005sr\000\024java.math.BigDecimalT\307\025W\371\201(O\002\000\002I\000\005scaleL\000\006intValt\000\026Ljava/math/BigInteger;xr\000\020java.lang.Number\206\254\225\035\013\224\340\213\002\000\000xp\000\000\000\000sr\000\024java.math.BigInteger\214\374\237\037\251;\373\035\002\000\006I\000\010bitCountI\000\011bitLengthI\000\023firstNonzeroByteNumI\000\014lowestSetBitI\000\006signum[\000\011magnitudet\000\002[Bxq\000~\000\002\377\377\377\377\377\377\377\377\377\377\377\376\377\377\377\376\000\000\000\001ur\000\002[B\254\363\027\370\006\010T\340\002\000\000xp\000\000\000\001\001'
      2002-07-09 19:29:43,168 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.insertEntity(JDBCCreateEntityCommand.java:199)
      2002-07-09 19:29:43,168 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.execute(JDBCCreateEntityCommand.java:131)
      2002-07-09 19:29:43,169 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:450)
      2002-07-09 19:29:43,169 ERROR [STDERR] at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:253)
      2002-07-09 19:29:43,170 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:270)
      2002-07-09 19:29:43,170 ERROR [STDERR] at org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:579)
      2002-07-09 19:29:43,171 ERROR [STDERR] at java.lang.reflect.Method.invoke(Native Method)
      2002-07-09 19:29:43,171 ERROR [STDERR] at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1116)
      2002-07-09 19:29:43,172 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:73)
      2002-07-09 19:29:43,173 ERROR [STDERR] at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:257)
      2002-07-09 19:29:43,173 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:215)

      blah, blah.

      --------------------------------------------------------
      Does anybody have any suggestions????

      Tom

        • 1. Re: BigDecimal Issue
          dsundstrom

          A lot of this code was rewritten for the 3.0.1 release. Try the 3.0.1 relese, and if it still doesn't work, post a bug report at sourceforge.

          • 2. Re: BigDecimal Issue
            tinnes

            I have downloaded 3.01 and the bug remains. I am posting a bug report today on this. Does anybody have a workaround????

            Tom

            • 3. Re: BigDecimal Issue
              dsundstrom

              I use PostgreSQL and it works for my BigDecimal test case. My testcase does not use Decimal(20).

              Can you write a small standalone java program that store and then loads a decimal(20) column (without errors)? If you can it will help me a lot in fixing this problem.

              • 4. Re: BigDecimal Issue
                rroland

                I have just encountered what appears to be the same problem with (a slightly customized) MS SQLSERVER datasource mapping. I have a cmp-field of type java.math.BigDecimal, I changed the mapping for java.math.BigDecimal in standardjbosscmp-jdbc.xml to DECIMAL, but the CMP runtime appears to ignore this mapping and is treating the field as if it was mapped as a plain java.long.Object (it's serializing the field). [I came to this conclusion based on the trace log]

                I found that if I add a <jdbc-type> (and <sql-type>) element directly to the <cmp-field> definition in the jbosscmp-jdbc.xml for the entity the field is mapped correctly and the code works.

                • 5. Re: BigDecimal Issue
                  rroland

                  Following up my own post... I think I spoke too soon. It appears I was incorrectly using <type-mapping> in the jbosscmp-jdbc.xml file instead of the currently expected element <datasource-mapping>.

                  • 6. Re: BigDecimal Issue
                    tinnes

                    The problem for me was an incorrectly defined setup file. I had not realized that I needed to configure the <datasource-mapping> of the standardjbosscmp-jdbc.xml file and change it to PostgreSQL 7.2. I also changed my DDL to be Numeric(20) though I am not sure if this is required.

                    Tom