Please help: Problem with Timestamp datatype in CMP key
yantriki Aug 10, 2004 2:29 PMHi 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)