> If I use the same OQL and mapping file I get different results running
> outside of jboss and in jboss as as a stateless session bean.
> 
> The retrieval works fine outside of jboss but I get errors if I attempt
> same OQL in stateless session bean deployed on jboss.  Problem is with
> collection of ProductCategory from ProductCategoryGroup.  Any ideas on
> what is wrong?
> 
> OQL statement:
> "SELECT p FROM com.trcinc.hm.business.product.ProductCategoryGroup p"
> 
> mapping for ProductCategoryGroup:
> 
>   <!--  Mapping for ProductCategoryGroup  -->
>   <class name="com.trcinc.hm.business.product.ProductCategoryGroup"
>          identity="groupId" key-generator="IDENTITY" >
>     <description>ProductCategoryGroup definition</description>
>     <map-to table="ProductCategoryGroup" xml="ProductCategoryGroup" />
> 
>     <field name="groupId" type="integer">
>       <sql name="groupId" type="integer" />
>       <xml name="groupId" node="attribute"/>
>     </field>
>         
>     <field name="groupCode" type="string">
>       <sql name="groupCode" type="varchar" />
>       <xml name="groupCode" node="attribute"/>
>     </field>
>     <field name="groupDescription" type="string" >
>       <sql name="groupDescription" type="varchar" />
>       <xml name="groupDescription" node="element" />
>     </field>
>     <field name="lastUpdatedDate" type="date" >
>       <sql name="lastUpdatedDate" type="timestamp" />
>       <xml name="lastUpdatedDate" node="element" />
>     </field>
>     
>     <field name="productCategory"
> type="com.trcinc.hm.business.product.ProductCategory" 
>            collection="arraylist" >
>       <xml name="productCategory" node="element"/>
>     </field>
>    
>     
>   </class>
> 
> mapping for ProductCategory:
> 
> 
>   <!--  Mapping for ProductCategory  -->
>   <class name="com.trcinc.hm.business.product.ProductCategory" 
>          identity="categoryId" key-generator="IDENTITY" >
>     <description>ProductCategory definition</description>
>     <map-to table="ProductCategory" xml="ProductCategory" />
> 
>     <field name="categoryId" type="integer">
>       <sql name="categoryId" type="integer" />
>       <xml name="categoryId" node="attribute"/>
>     </field>
>         
>     <field name="categoryCode" type="string">
>       <sql name="categoryCode" type="varchar" />
>       <xml name="categoryCode" node="attribute"/>
>     </field>
> 
>     <field name="productCategoryGroup"
> type="com.trcinc.hm.business.product.ProductCategoryGroup">
>       <sql name="groupId" />
>       <xml name="productCategoryGroup" node="element" />
>     </field>
> 
>     <field name="description" type="string" >
>       <sql name="description" type="varchar" />
>       <xml name="description" node="element" />
>     </field>
>     <field name="lastUpdatedDate" type="date" >
>       <sql name="lastUpdatedDate" type="timestamp" />
>       <xml name="lastUpdatedDate" node="element" />
>     </field>
>     <!--
>     <field name="products" type="com.trcinc.hm.business.product.Product" 
>            collection="arraylist" >
>       <sql many-key="productId" />
>       <xml name="product" node="element"/>
>     </field>
>     -->
>   </class>
> 
> When deployed as EJB on jboss get error:
> 
> [ProductService] helper oql
> org.exolab.castor.jdo.engine.OQLQueryImpl@5f157b
> [ProductService] helper coll err No add method defined for this field
> [ProductService] java.lang.RuntimeException: No add method defined for
> this fiel
> d
> [ProductService]        at
> org.exolab.castor.persist.FieldMolder.addValue(FieldM
> older.java:259)
> [ProductService]        at
> org.exolab.castor.persist.CollectionProxy$ColProxy.ad
> d(ClassMolder.java:2644)
> [ProductService]        at
> org.exolab.castor.persist.ClassMolder.load(ClassMolde
> r.java:723)
> [ProductService]        at
> org.exolab.castor.persist.LockEngine.load(LockEngine.
> java:354)
> [ProductService]        at
> org.exolab.castor.persist.TransactionContext.load(Tra
> nsactionContext.java:489)
> [ProductService]        at
> org.exolab.castor.persist.QueryResults.fetch(QueryRes
> ults.java:219)
> [ProductService]        at
> org.exolab.castor.jdo.engine.OQLQueryImpl$OQLEnumerat
> ion.hasMore(OQLQueryImpl.java:546)
> [ProductService]        at
> org.exolab.castor.jdo.engine.OQLQueryImpl$OQLEnumerat
> ion.hasMore(OQLQueryImpl.java:529)
> [ProductService]        at
> com.trcinc.hm.ekiss.util.CastorProductHelper.findColl
> ection(CastorProductHelper.java:113)
> [ProductService]        at
> com.trcinc.hm.ekiss.beans.EJBProductServiceDAO.getPro
> ductGroups(EJBProductServiceDAO.java:88)
> [ProductService]        at
> com.trcinc.hm.ekiss.beans.EJBProductServiceBean.getPr
> oductGroups(EJBProductServiceBean.java:101)
> [ProductService]        at java.lang.reflect.Method.invoke(Native Method)
> [ProductService]        at
> org.jboss.ejb.StatelessSessionContainer$ContainerInte
> rceptor.invoke(StatelessSessionContainer.java:472)
> [ProductService]        at
> org.jboss.ejb.plugins.StatelessSessionInstanceInterce
> ptor.invoke(StatelessSessionInstanceInterceptor.java:87)
> [ProductService]        at
> org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxI
> nterceptorCMT.java:133)
> [ProductService]        at
> org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransac
> tions(TxInterceptorCMT.java:264)
> [ProductService]        at
> org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInter
> ceptorCMT.java:99)
> [ProductService]        at
> org.jboss.ejb.plugins.SecurityInterceptor.invoke(Secu
> rityInterceptor.java:137)
> [ProductService]        at
> org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterc
> eptor.java:195)
> [ProductService]        at
> org.jboss.ejb.StatelessSessionContainer.invoke(Statel
> essSessionContainer.java:271)
> [ProductService]        at
> org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoke
> r.invoke(JRMPContainerInvoker.java:381)
> [ProductService]        at java.lang.reflect.Method.invoke(Native Method)
> [ProductService]        at
> sun.rmi.server.UnicastServerRef.dispatch(UnicastServe
> rRef.java:241)
> [ProductService]        at
> sun.rmi.transport.Transport$1.run(Transport.java:142)
> 
> [ProductService]        at
> java.security.AccessController.doPrivileged(Native Me
> thod)
> [ProductService]        at
> sun.rmi.transport.Transport.serviceCall(Transport.jav
> a:139)
> [ProductService]        at
> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCP
> Transport.java:443)
> [ProductService]        at
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.
> run(TCPTransport.java:643)
> [ProductService]        at java.lang.Thread.run(Thread.java:484)
> 
> java for ProductCategoryGroup - there is a addProductCategory method:
> 
> public class ProductCategoryGroup implements java.io.Serializable,
> Persistent, TimeStampable {
> 
> 
>       //--------------------------/
>      //- Class/Member Variables -/
>     //--------------------------/
> 
>     private int _groupId;
> 
>     /**
>      * keeps track of state for field: _groupId
>     **/
>     private boolean _has_groupId;
> 
>     private java.lang.String _groupCode;
> 
>     private java.lang.String _groupDescription;
> 
>     private java.util.Date _lastUpdatedDate;
> 
>     private java.util.ArrayList _productCategoryList;
>     
>     private Database     _db;
>     
>     private long         _timestamp;
> 
> 
>       //----------------/
>      //- Constructors -/
>     //----------------/
> 
>     public ProductCategoryGroup() {
>         super();
>         _productCategoryList = new ArrayList();
>     } //-- com.trcinc.hm.business.product.ProductCategoryGroup()
> 
> 
>       //-----------/
>      //- Methods -/
>     //-----------/
> 
>     /**
>      * 
>      * @param vProductCategory
>     **/
>     public void addProductCategory(ProductCategory vProductCategory)
>         throws java.lang.IndexOutOfBoundsException
>     {
>         vProductCategory.setProductCategoryGroup(this);
>         _productCategoryList.add(vProductCategory);
>     } //-- void addProductCategory(ProductCategory) 
> 
>     /**
>     **/
>     public void clearProductCategory()
>     {
>         _productCategoryList.clear();
>     } //-- void clearProductCategory() 
> 
>     /**
>     **/
>     public java.lang.String getGroupCode()
>     {
>         return this._groupCode;
>     } //-- java.lang.String getGroupCode() 
> 
>     /**
>     **/
>     public java.lang.String getGroupDescription()
>     {
>         return this._groupDescription;
>     } //-- java.lang.String getGroupDescription() 
> 
>     /**
>     **/
>     public int getGroupId()
>     {
>         return this._groupId;
>     } //-- int getGroupId() 
> 
>     /**
>     **/
>     public java.util.Date getLastUpdatedDate()
>     {
>         return this._lastUpdatedDate;
>     } //-- java.util.Date getLastUpdatedDate() 
> 
>     public ArrayList getProductCategory()
>     {
>         System.out.println("group get cats " +
> _productCategoryList.size());
>         return _productCategoryList;
>     }
> 
>     /**
>     **/
>     public int getProductCategoryCount()
>     {
>         return _productCategoryList.size();
>     } //-- int getProductCategoryCount() 
> 
>     /**
>     **/
>     public boolean hasGroupId()
>     {
>         return this._has_groupId;
>     } //-- boolean hasGroupId() 
> 
>     /**
>     **/
>     public boolean isValid()
>     {
>         try {
>             validate();
>         }
>         catch (org.exolab.castor.xml.ValidationException vex) {
>             return false;
>         }
>         return true;
>     } //-- boolean isValid() 
> 
>     /**
>      * 
>      * @param out
>     **/
>     public void marshal(java.io.Writer out)
>         throws org.exolab.castor.xml.MarshalException,
> org.exolab.castor.xml.ValidationException
>     {
>         
>         Marshaller.marshal(this, out);
>     } //-- void marshal(java.io.Writer) 
> 
>     /**
>      * 
>      * @param handler
>     **/
>     public void marshal(org.xml.sax.DocumentHandler handler)
>         throws org.exolab.castor.xml.MarshalException,
> org.exolab.castor.xml.ValidationException
>     {
>         
>         Marshaller.marshal(this, handler);
>     } //-- void marshal(org.xml.sax.DocumentHandler) 
> 
>     /**
>      * 
>      * @param vProductCategory
>     **/
>     public boolean removeProductCategory(ProductCategory vProductCategory)
>     {
>         boolean removed = _productCategoryList.remove(vProductCategory);
>         return removed;
>     } //-- boolean removeProductCategory(ProductCategory) 
> 
>     /**
>      * 
>      * @param _groupCode
>     **/
>     public void setGroupCode(java.lang.String _groupCode)
>     {
>         this._groupCode = _groupCode;
>     } //-- void setGroupCode(java.lang.String) 
> 
>     /**
>      * 
>      * @param _groupDescription
>     **/
>     public void setGroupDescription(java.lang.String _groupDescription)
>     {
>         this._groupDescription = _groupDescription;
>     } //-- void setGroupDescription(java.lang.String) 
> 
>     /**
>      * 
>      * @param _groupId
>     **/
>     public void setGroupId(int _groupId)
>     {
>         this._groupId = _groupId;
>         this._has_groupId = true;
>     } //-- void setGroupId(int) 
> 
>     /**
>      * 
>      * @param _lastUpdatedDate
>     **/
>     public void setLastUpdatedDate(java.util.Date _lastUpdatedDate)
>     {
>         this._lastUpdatedDate = _lastUpdatedDate;
>     } //-- void setLastUpdatedDate(java.util.Date) 
> 
> 
>     /**
>      * 
>      * @param reader
>     **/
>     public static com.trcinc.hm.business.product.ProductCategoryGroup
> unmarshal(java.io.Reader reader)
>         throws org.exolab.castor.xml.MarshalException,
> org.exolab.castor.xml.ValidationException
>     {
>         return (com.trcinc.hm.business.product.ProductCategoryGroup)
> Unmarshaller.unmarshal(com.trcinc.hm.business.product.ProductCategoryGroup
> .class, reader);
>     } //-- com.trcinc.hm.business.product.ProductCategoryGroup
> unmarshal(java.io.Reader) 
> 
>     /**
>     **/
>     public void validate()
>         throws org.exolab.castor.xml.ValidationException
>     {
>         org.exolab.castor.xml.Validator validator = new
> org.exolab.castor.xml.Validator();
>         validator.validate(this);
>     } //-- void validate() 
>     
>     public void jdoPersistent( Database db )
>     {
>         _db = db;
>     }
> 
> 
>     public void jdoTransient()
>     {
>         _db = null;
>     }
> 
> 
>     public Class jdoLoad(short accessMode)
>     {    
>         return this.getClass();
>     }
> 
>     public void jdoCreate() 
>     {
>     }
>     
>     public void jdoAfterCreate() 
>     {
>     }
> 
> 
>     public void jdoStore(boolean modified)
>     {
>     }
> 
>     public void jdoRemove()
>     {
>     }
>     
>     public void jdoBeforeRemove()
>     {
>     }
> 
>     public void jdoUpdate() 
>     {
>     }
> 
>     public void jdoBeforeCreate( Database db )
>     {
>     }
> 
>      public void jdoAfterRemove()
>     {
>     }
> 
>     /** Set the timestamp.
>      *
>      * @param timestamp The timestamp
>      */
>     public void jdoSetTimeStamp(long timestamp) {
>         this._timestamp = timestamp;
>     }
>     /** Get the timestamp.
>      * NOTE: immediately after the object creation this method must return
> 0,
>      * this is an indication of the new object.
>      */
>     public long jdoGetTimeStamp() {
>         return this._timestamp;
>     }
> }
> 
> Thanks for your help,
> Ruan
> 
> 


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]

Reply via email to