1 Reply Latest reply on May 5, 2005 5:37 AM by Guillermo Guisado

    JBoss calling PK class Constructor with null (compund Key)

    Guillermo Guisado Newbie

      Hi:
      Jboss is calling with null on the Constractor of a PK class with a compound key after calling a finder that searches by one of the two fields of the key.

      ejb-jar.xml

      <entity>
       <display-name>CouponPayments</display-name>
       <ejb-name>CouponPaymentEJB</ejb-name>
       <abstract-schema-name>CouponPayments</abstract-schema-name>
       <home>com.db.gto.cio.gm.it.madrid.dbsales.ejbs.CouponPaymentHomeRemote</home>
       <remote>com.db.gto.cio.gm.it.madrid.dbsales.ejbs.CouponPaymentRemote</remote>
       <ejb-class>com.db.gto.cio.gm.it.madrid.dbsales.ejbs.CouponPaymentBean</ejb-class>
       <persistence-type>Container</persistence-type>
       <prim-key-class>com.db.gto.cio.gm.it.madrid.dbsales.ejbs.CouponPaymentPK</prim-key-class>
       <reentrant>False</reentrant>
       <cmp-version>2.x</cmp-version>
       <cmp-field><field-name>bondsId</field-name></cmp-field>
       <cmp-field><field-name>couponDate</field-name></cmp-field>
       <query>
       <query-method>
       <method-name>findByBondsId</method-name>
       <method-params>
       <method-param>java.lang.Integer</method-param>
       </method-params>
       </query-method>
       <ejb-ql/>
       </query></entity>


      Pk class:

      package com.db.gto.cio.gm.it.madrid.dbsales.ejbs;
      
      
      public class BondStripPK implements java.io.Serializable {
      
       public Integer bondsId;
       public Integer bondsIdSTRIP;
      
       public BondStripPK(Integer BondsId, Integer BondsIdSTRIP){
       this.bondsId = BondsId;
       this.bondsIdSTRIP = BondsIdSTRIP;
      
       System.out.println("bondsId: " + bondsId + ". bondsIdSTRIP: " + bondsIdSTRIP);
       }
      
       public Integer getBondsId(){
       return(bondsId);
       }
      
       public Integer getBondsIdSTRIP(){
       return(bondsIdSTRIP);
       }
       public boolean equals(Object bondStripPKObject){
       System.out.println("EQUALS bondsId: " + bondsId + ". bondsIdSTRIP: " + bondsIdSTRIP);
       if (bondStripPKObject instanceof BondStripPK) {
       BondStripPK bondStripPK = (BondStripPK)bondStripPKObject;
       return(bondStripPK.bondsId.equals(bondsId)
       && bondStripPK.bondsIdSTRIP.equals(bondsIdSTRIP));
       }
       else{
       return(false);
       }
       }
       public BondStripPK()
       {
       }
      
      
       public int hashCode(){
       StringBuffer buff = new StringBuffer ();
       buff.append(bondsId);
       buff.append("-");
       buff.append(bondsIdSTRIP);
       int hashCode =buff.toString().hashCode();
       return hashCode;
       }
      
      }
      


      error:


      18:45:54,019 INFO [STDOUT] EQUALS bondsId: 88011. bondsIdSTRIP: null
      18:45:54,019 ERROR [BondStripEJB#findByBondsId] Find failed
      java.lang.NullPointerException
       at com.db.gto.cio.gm.it.madrid.dbsales.ejbs.BondStripPK.equals(BondStripPK.java:30)
       at org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache$PreloadKey.equals(ReadAheadCache.java:730)
       at java.util.HashMap.eq(HashMap.java:274)
       at java.util.HashMap.get(HashMap.java:323)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.getEntityTxData(JDBCStoreManager.java:294)
       at org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.getPreloadDataMap(ReadAheadCache.java:555)
       at org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.addPreloadData(ReadAheadCache.java:475)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractQueryCommand$EagerCollectionFactory.createCollection(JDBCAbstractQueryCommand.
      java:712)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractQueryCommand.execute(JDBCAbstractQueryCommand.java:226)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractQueryCommand.execute(JDBCAbstractQueryCommand.java:128)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCFindEntitiesCommand.execute(JDBCFindEntitiesCommand.java:40)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.findEntities(JDBCStoreManager.java:598)
       at org.jboss.ejb.plugins.CMPPersistenceManager.findEntities(CMPPersistenceManager.java:322)
       at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.findEntities(CachedConnectionInterceptor.java:321)
       at org.jboss.ejb.EntityContainer.find(EntityContainer.java:700)
       at sun.reflect.GeneratedMethodAccessor120.invoke(Unknown Source)
       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.invokeHome(EntityContainer.java:1113)
       at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:90)
       at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:192)
       at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:212)
       at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:90)
       at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:113)
       at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:61)
       at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:28)
       at org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:41)
       at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:109)
       at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:316)
       at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:129)
       at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:106)
       at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120)
       at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
       at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:508)
       at org.jboss.ejb.Container.invoke(Container.java:876)
       at sun.reflect.GeneratedMethodAccessor118.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
       at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:155)
       at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:104)
       at org.jboss.invocation.MarshallingInvokerInterceptor.invoke(MarshallingInvokerInterceptor.java:55)
       at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
       at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
       at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:169)
       at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:86)
       at $Proxy433.findByBondsId(Unknown Source)
      


      Any ideas?