Known bug.

On tor, 2002-06-06 at 23:24, Peter Coppens wrote:
> Hi,
> 
> I wonder whether anyone has experienced problems with one-to-many CMR, where
> the many bean has a composite primary key.
> 
> It is a 'typical' vendor-vendoritems relation. Primary key for the vendor is
> email, primary key for the vendoritem is (email,id).
> 
> The code is below and it throws an exception when accessing any of the
> vendoritems attributes.
> 
> The 'strange' thing is that when there is only one vendoritem for a given
> vendor it works fine. When there is more than one, I get the exception as
> listed after the code.
> When I make the primary key in the vendoritem just the id, it works fine as
> well.
> 
> Tracing what is returned from the RDBMS looks ok to me.
> 
> Thanks,
> 
> Peter
> 
> 
> ------------
> Code extract
> ------------
>     public LolVendorItemInfo[] getVendorItems ( String email )
>       {
>       try
>         {
>         ArrayList lolVendorItemList = new ArrayList ( 50 );
>         LolVendor lolVendor = this.lolVendorHome.findByPrimaryKey ( email );
>         Collection lolVendorItemColl = lolVendor.getItems ( );
>         Iterator lolVendorItemIterator = lolVendorItemColl.iterator ( );
>         while ( lolVendorItemIterator.hasNext ( ) )
>           {
>           try
>             {
>             LolVendorItem lolVendorItem = ( LolVendorItem )
> lolVendorItemIterator.next ( ); 
>             LolVendorItemInfo lolVendorItemInfo = new LolVendorItemInfo (
> lolVendor.getEmail ( ) );
>             lolVendorItemInfo.setItemId ( lolVendorItem.getId ( ) ); /*
> Exception is thrown here */
>             lolVendorItemInfo.setItemDescription (
> lolVendorItem.getDescription ( ) );
>             lolVendorItemInfo.setItemPrice ( lolVendorItem.getPrice ( ) );
>             lolVendorItemList.add ( lolVendorItemInfo );
>             }
>           catch ( Exception e ) 
>             {
>             e.printStackTrace ( System.out );
>             }
>           }
>         return ( LolVendorItemInfo[] ) lolVendorItemList.toArray ( new
> LolVendorItemInfo [ lolVendorItemList.size ( ) ] );
>         }
>       catch ( FinderException e ) 
>         {
>         throw new EJBException ( "Unable to get list of vendor items ", e );
>         }
>       }
> 
> -------------------------
> Small part of stack trace
> -------------------------
> 2002-06-06 12:36:37,992 DEBUG
> [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.LolVendorItemBean]
> Executing SQL: SELECT Email, Id,Description, Price FROM lol_vendoritem WHERE
> (Email=? AND Id=?) OR (Email=? AND Id=?) OR (Email=? AND Id=?) OR (Email=?
> AND Id=?) OR (Email=? AND Id=?) OR (Email=? AND Id=?) OR (Email=? AND Id=?)
> OR (Email=? AND Id=?) OR (Email=? AND Id=?) OR (Email=? AND Id=?)
> 2002-06-06 12:36:38,123 ERROR [org.jboss.ejb.plugins.LogInterceptor]
> TransactionRolledbackException, causedBy:
> javax.ejb.NoSuchEntityException: Entity not found:
> primaryKey=com.ddtek.lol.LolVendorItemPK@f92a41
>       at
> org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityC
> ommand.java:165)
> ....
> 
> -----------
> Part of ejb-jar.xml
> -----------
> 
>     <entity>
>       <display-name>LolVendorBean</display-name>
>       <ejb-name>LolVendorBean</ejb-name>
> 
>       <local-home>com.ddtek.lol.LolVendorHome</local-home>
>       <local>com.ddtek.lol.LolVendor</local>
>       <ejb-class>com.ddtek.lol.LolVendorBean</ejb-class>
> 
>       <persistence-type>Container</persistence-type>
>       <prim-key-class>java.lang.String</prim-key-class>
> 
>       <reentrant>True</reentrant>
>       <cmp-version>2.x</cmp-version>
> 
>       <abstract-schema-name>LolVendorBean</abstract-schema-name>
> 
>       <cmp-field>
>         <description>no description</description>
>         <field-name>Email</field-name>
>       </cmp-field>
>       <cmp-field>
>         <description>no description</description>
>         <field-name>Name</field-name>
>       </cmp-field>
>       <cmp-field>
>         <description>no description</description>
>         <field-name>Phone</field-name>
>       </cmp-field>
>       <cmp-field>
>         <description>no description</description>
>         <field-name>Fax</field-name>
>       </cmp-field>
>       <cmp-field>
>         <description>no description</description>
>         <field-name>StreetAndNr</field-name>
>       </cmp-field>
>       <cmp-field>
>         <description>no description</description>
>         <field-name>PostalCode</field-name>
>       </cmp-field>
>       <cmp-field>
>         <description>no description</description>
>         <field-name>City</field-name>
>       </cmp-field>
> 
>       <primkey-field>Email</primkey-field>
> 
>       <security-identity>
>         <description></description>
>         <use-caller-identity></use-caller-identity>
>       </security-identity>
> 
>       <query>
>         <description></description>
>         <query-method>
>           <method-name>findAll</method-name>
>           <method-params />
>         </query-method>
>         <ejb-ql>select Object(o) from LolVendorBean as o</ejb-ql>
>       </query>
> 
>     </entity>
>     
> 
>     <entity>
>       <display-name>LolVendorItemBean</display-name>
>       <ejb-name>LolVendorItemBean</ejb-name>
> 
>       <local-home>com.ddtek.lol.LolVendorItemHome</local-home>
>       <local>com.ddtek.lol.LolVendorItem</local>
>       <ejb-class>com.ddtek.lol.LolVendorItemBean</ejb-class>
> 
>       <persistence-type>Container</persistence-type>
> 
>       <reentrant>True</reentrant>
>       <cmp-version>2.x</cmp-version>
> 
>       <abstract-schema-name>LolVendorItemBean</abstract-schema-name>
> 
>       <cmp-field>
>         <description>no description</description>
>         <field-name>Email</field-name>
>       </cmp-field>
>       <cmp-field>
>         <description>no description</description>
>         <field-name>Id</field-name>
>       </cmp-field>
>       <cmp-field>
>         <description>no description</description>
>         <field-name>Description</field-name>
>       </cmp-field>
>       <cmp-field>
>         <description>no description</description>
>         <field-name>Price</field-name>
>       </cmp-field>
> 
>       <prim-key-class>com.ddtek.lol.LolVendorItemPK</prim-key-class>
> 
>       <security-identity>
>         <description></description>
>         <use-caller-identity></use-caller-identity>
>       </security-identity>
> 
>       <query>
>         <description></description>
>         <query-method>
>           <method-name>findAll</method-name>
>           <method-params />
>         </query-method>
>         <ejb-ql>select Object(o) from LolVendorBean as o</ejb-ql>
>       </query>
> 
>     </entity>
> .....
>     <ejb-relation>
>       <ejb-relation-name>VendorSellsItems</ejb-relation-name>
> 
>       <ejb-relationship-role>
>  
> <ejb-relationship-role-name>VendorSellsItems</ejb-relationship-role-name>
>         <multiplicity>One</multiplicity>
>         <relationship-role-source>
>           <ejb-name>LolVendorBean</ejb-name>
>         </relationship-role-source>
>         <cmr-field>
>           <cmr-field-name>Items</cmr-field-name>
>           <cmr-field-type>java.util.Collection</cmr-field-type>
>         </cmr-field>
>       </ejb-relationship-role>
> 
>       <ejb-relationship-role>
>  
> <ejb-relationship-role-name>ItemIsSoldByVendor</ejb-relationship-role-name>
>         <multiplicity>Many</multiplicity>
>         <relationship-role-source>
>           <ejb-name>LolVendorItemBean</ejb-name>
>         </relationship-role-source>
>         <cmr-field>
>           <cmr-field-name>Vendor</cmr-field-name>
>         </cmr-field>
>       </ejb-relationship-role>
> 
>     </ejb-relation>
> 
> _______________________________________________________________
> 
> Don't miss the 2002 Sprint PCS Application Developer's Conference
> August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
> 
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user



_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to