3 Replies Latest reply on Aug 10, 2004 4:33 PM by Vivek Srivastav

    Please help: Problem with Timestamp datatype in CMP key

    Vivek Srivastav Newbie

      Hi All,
      I am stuck up with a desparate problem. I can write data using my bean but can't read data back (Please see the exception attached). My CMP has a java.sql.Timestamp data in the composit primary key. I think I am doing something wrong with the jdbc-type sql-type mapping, but even after using different combination of these type I am unable to get it to work.

      Following is the definition of the CMP:

      -----------------------------------------
      Entity definition from jbosscmp-jdbc.xml file
      -----------------------------------------------------

      <ejb-name>CardHistory</ejb-name>
      <create-table>true</create-table>
      <remove-table>false</remove-table>

      <table-name>CardHistory</table-name>

      <cmp-field>
      <field-name>pollTime</field-name>
      <column-name>pollTime</column-name>

      <jdbc-type>TIMESTAMP</jdbc-type>
      <sql-type>DATETIME</sql-type>

      </cmp-field>
      <cmp-field>
      <field-name>serialNo</field-name>
      <column-name>serialNo</column-name>

      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(12)</sql-type>

      </cmp-field>
      <cmp-field>
      <field-name>cardHistoryParamID</field-name>
      <column-name>cardHistoryParamID</column-name>

      <jdbc-type>SMALLINT</jdbc-type>
      <sql-type>SMALLINT</sql-type>

      </cmp-field>
      <cmp-field>
      <field-name>value</field-name>
      <column-name>value</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>isOnTrap</field-name>
      <column-name>isOnTrap</column-name>

      </cmp-field>

      <unknown-pk>
      <unknown-pk-class>optinel.ejb.HistoryKey</unknown-pk-class>
      </unknown-pk>
      <!-- jboss 3.2 features -->
      <!-- optimistic locking does not express the exclusions needed -->

      --------------------------------------------------------
      Table definition
      --------------------------------------------------------

      CREATE TABLE [CardHistory] (
      [pollTime] [datetime] NOT NULL ,
      [serialNo] [varchar] (12) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
      [cardHistoryParamID] [smallint] NOT NULL ,
      [value] [bigint] NULL ,
      [isOnTrap] [bit] NULL ,
      CONSTRAINT [pk_CardHistory] PRIMARY KEY CLUSTERED
      (
      [pollTime],
      [serialNo],
      [cardHistoryParamID]
      ) ON [PRIMARY]
      ) ON [PRIMARY]
      GO



      I am using MSSQL 2000 database.


      Exception
      -------------
      14:11:06,761 ERROR [LogInterceptor] TransactionRolledbackLocalException in method: public abstract java.sql.Timestamp optinel.iface.CardHistoryLocal.getPollTime(), causedBy:
      javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=Time: 2004-08-10 01:58:00.0 Param:4 SN:026003
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:158)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:484)
      at org.jboss.ejb.Container.invoke(Container.java:723)
      at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:359)
      at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:44)
      at $Proxy216.getPollTime(Unknown Source)


        • 1. Re: Please help: Problem with Timestamp datatype in CMP key
          Vivek Srivastav Newbie

          Oops! Following is my EJB finder definitions for CardHistory CMP:


          * @ejb.finder
          * signature = "java.util.Collection findAllByParamAndCard(java.lang.Integer cardHistoryParamID, java.lang.String serialNo)"
          * query = "SELECT OBJECT(p) FROM CardHistory as p WHERE p.cardHistoryParamID = ?1 AND p.serialNo = ?2 ORDER BY p.cardHistoryParamID, p.pollTime"
          * unchecked = "true"
          *
          * @ejb.finder
          * signature = "java.util.Collection findByParamCardAndRecentThan(java.lang.Integer cardHistoryParamID, java.lang.String serialNo, java.util.Date d)"
          * query = "SELECT OBJECT(p) FROM CardHistory as p WHERE p.cardHistoryParamID = ?1 AND p.serialNo = ?2 AND p.pollTime > ?3 ORDER BY p.cardHistoryParamID, p.pollTime"
          * unchecked = "true"
          *
          * @ejb.finder
          * signature = "java.util.Collection findByOlderThanDate(java.sql.Timestamp ts)"
          * query = "SELECT OBJECT(p) FROM CardHistory as p WHERE p.pollTime < ?1 ORDER BY p.serialNo, p.cardHistoryParamID, p.pollTime"
          * unchecked = "true"

          • 2. Re: Please help: Problem with Timestamp datatype in CMP key
            Vivek Srivastav Newbie

            Another thing I noticed. When I have just one record, I am able to use the CMP bean to read the data. however it throws this exception as soon as there are more than 1 record.

            • 3. Re: Please help: Problem with Timestamp datatype in CMP key
              Vivek Srivastav Newbie

              Hi,
              I changed the timestamp column to BIGINT and still get the same error. So I think there must be some other problem with my code.


              16:26:50,399 ERROR [LogInterceptor] TransactionRolledbackLocalException in method: public abstract java.lang.Long optinel.iface.CardHistoryLocal.getPollTime(), causedBy:
              javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=Time: 1092126316034 Param:4 SN:026003
              at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:158)
              at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
              at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
              at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
              at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
              at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
              at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:484)
              at org.jboss.ejb.Container.invoke(Container.java:723)
              at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:359)
              at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:44)
              at $Proxy340.getPollTime(Unknown Source)
              at optinel.ejb.StatsEngineBean.getHistoryByParamAndCard(StatsEngineBean.java:170)
              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.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
              at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
              at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
              at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
              at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
              at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
              at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
              at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
              at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
              at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
              at org.jboss.ejb.Container.invoke(Container.java:723)
              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.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
              at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360)
              at sun.reflect.GeneratedMethodAccessor90.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:324)
              at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
              at sun.rmi.transport.Transport$1.run(Transport.java:148)
              at java.security.AccessController.doPrivileged(Native Method)
              at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
              at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
              at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
              at java.lang.Thread.run(Thread.java:534)
              16:26:50,415 INFO [STDOUT] Exception getting card history: Entity not found: primaryKey=Time: 1092126316034 Param:4 SN:026003; CausedByException is:
              Entity not found: primaryKey=Time: 1092126316034 Param:4 SN:026003
              16:26:50,415 ERROR [LogInterceptor] TransactionRolledbackException in method: public abstract optinel.iface.CardHistoryValue[] optinel.remote.StatsEngine.getHistoryByParamAndCard(java.lang.Integer,java.lang.String) throws java.lang.Exception,java.rmi.RemoteException, causedBy:
              javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=Time: 1092126316034 Param:4 SN:026003
              at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:158)
              at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
              at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
              at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
              at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
              at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
              at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:484)
              at org.jboss.ejb.Container.invoke(Container.java:723)
              at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:359)
              at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:44)
              at $Proxy340.getPollTime(Unknown Source)
              at optinel.ejb.StatsEngineBean.getHistoryByParamAndCard(StatsEngineBean.java:170)
              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.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
              at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
              at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
              at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
              at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
              at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
              at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
              at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
              at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
              at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
              at org.jboss.ejb.Container.invoke(Container.java:723)
              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.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
              at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360)
              at sun.reflect.GeneratedMethodAccessor90.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:324)
              at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
              at sun.rmi.transport.Transport$1.run(Transport.java:148)
              at java.security.AccessController.doPrivileged(Native Method)
              at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
              at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
              at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
              at java.lang.Thread.run(Thread.java:534)