0 Replies Latest reply on Dec 19, 2005 9:58 AM by sivakumar_n

    ClassCast Exception in Primary Key Generation with Custom En

    sivakumar_n

      I have written a custom implementation for Primary Key Generation using entity command. This implementation works fine for entity beans having Integer as Primary Key Class. The Class Cast Exception is being thrown for the beans having java.lang.Long as primary key Class.

      I have the following ejb doclet code in my bean

      * @jboss.entity-command name="key_gen"
       * @jboss.entity-command-attribute
       * name="sequence"
       * value="eventid"
       *
       * @jboss.unknown-pk
       * class="java.lang.Long"
       * column-name="eventid"
       * jdbc-type="LONG"
       * sql-type="LONG"
       * auto-increment="true"
      


      The exception is thrown when i call local.getEventId() method .


      java.lang.ClassCastException
       at EventBean$Proxy.getEventid(<generated>)
       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.invocation.Invocation.performCall(Invocation.java:345)
       at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1174)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:72)
       at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:273)
       at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
       at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:111)
       at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:242)
       at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
       at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:53)
       at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
       at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
       at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:313)
       at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:146)
       at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:122)
       at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
       at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
       at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:514)
       at org.jboss.ejb.Container.invoke(Container.java:870)
       at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:413)
       at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:44)
       at $Proxy554.getEventid(Unknown Source)
      


      Where should i specify the primary class as java.lang.Long to avoid this exception.

      Thanks
      Siva