4 Replies Latest reply on Jul 17, 2004 4:42 AM by aloubyansky

    cmp performance problem with getmethod

    smilidon

      Hi,

      i have a cmp bean "Minfo" and get my results in my client this way:

      code:


      try {
      Collection c = getHome().findByDisk(disk);
      Iterator iterator = c.iterator();

      Minfo info = null;
      while (iterator.hasNext()){
      Object obj = iterator.next();
      if (obj instanceof Minfo) info = (Minfo)obj;
      System.out.println(info.getDisk()+" "+ info.getExtension());
      }
      } catch (RemoteException e1) {
      e1.printStackTrace();



      Every time i call a get-function, JBoss make a database query like this:

      Executing SQL: SELECT filename, extension, disk, size, id3title, id3artist, id3length, id3bitrate FROM minfo WHERE (id=?)

      is it possible to get the information for all get-functions with one sql-call for each bean? is it possible to configure my bean or jboss for this behavior? if the finder has a result, is it possible to load all the bean data? or is there a other way i can improve performance?

      i have a performance problem if i call a lot of get-Methods.

      Thanks a lot and sorry for my bad english.

      P.S.I don't have the Admin and Dev book

        • 1. Re: cmp performance problem with getmethod
          kabirkhan

          You need to execute in the context of a transaction. The Admin and Devel docs are available from the big blue picture on the right that say "Free JBoss Documentation" :-)

          • 2. Re: cmp performance problem with getmethod
            smilidon

            ok, thanks :)

            i try it and i have a problem to add this tags to my jbosscmp-jdbc.xml

             <load-groups>
             <load-group>
             <load-group-name>all</load-group-name>
             <field-name>filename</field-name>
             <field-name>extension</field-name>
             <field-name>disk</field-name>
             <field-name>size</field-name>
             <field-name>id3title</field-name>
             <field-name>id3artist</field-name>
             <field-name>id3length</field-name>
             <field-name>id3bitrate</field-name>
             </load-group>
             <eager-load-group>all</eager-load-group>
             </load-groups>


            i get the exception:

            16:04:55,408 INFO [EjbModule] Deploying Minfo
            16:04:55,596 ERROR [XmlFileLoader] XmlFileLoader: File jar:file:/D:/Coding/jboss-3.2.5/server/default/tmp/deploy/tmp44502MediaMod.jar!/META-INF/jbosscmp-jdbc.xml process error. Line: 87. Error message: The content of element type "load-groups" must match "(load-group)+".
            16:04:55,596 ERROR [EntityContainer] Starting failed jboss.j2ee:jndiName=MinfoBean,service=EJB
            org.jboss.deployment.DeploymentException: Invalid XML: file=jar:file:/D:/Coding/jboss-3.2.5/server/default/tmp/deploy/tmp44502MediaMod.jar!/META-INF/jbosscmp-jdbc.xml
            at org.jboss.metadata.XmlFileLoader.getDocument(XmlFileLoader.java:296)
            at org.jboss.metadata.XmlFileLoader.getDocument(XmlFileLoader.java:247)
            at org.jboss.metadata.XmlFileLoader.getDocumentFromURL(XmlFileLoader.java:219)
            at org.jboss.metadata.XmlFileLoader.getDocument(XmlFileLoader.java:203)
            at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader.load(JDBCXmlFileLoader.java:74)
            .
            .
            .

            if i delete the line <eager-load-group>all</eager-load-group>, i can deploy, but it doesnt change anything.
            i also get an exception if i put these lines except <eager-load-group>all</eager-load-group> to the top or bottom of jbosscmp-jdbc.xml(in tag). it must be placed between the cmp-fields and the querys?!?!

            here is more of my jbosscmp-jdbc.xml

            <jbosscmp-jdbc>
             <defaults>
             <datasource>java:/MySqlDS</datasource>
             <datasource-mapping>mySQL</datasource-mapping>
             <preferred-relation-mapping>foreign-key</preferred-relation-mapping>
             </defaults>
            
             <enterprise-beans>
            
             <!--
             To add beans that you have deployment descriptor info for, add
             a file to your XDoclet merge directory called jbosscmp-jdbc-beans.xml
             that contains the <entity></entity> markup for those beans.
             -->
            
             <entity>
             <ejb-name>Minfo</ejb-name>
            
             <read-ahead>
             <strategy>on-load</strategy>
             <page-size>4</page-size>
             <eager-load-group>all</eager-load-group>
             </read-ahead>
             <table-name>minfo</table-name>
            
             <cmp-field>
             <field-name>filename</field-name>
             <column-name>filename</column-name>
            
             </cmp-field>
            .
            .
            .
             <load-groups>
             <load-group>
             <load-group-name>all</load-group-name>
             <field-name>filename</field-name>
             <field-name>extension</field-name>
             <field-name>disk</field-name>
             <field-name>size</field-name>
             <field-name>id3title</field-name>
             <field-name>id3artist</field-name>
             <field-name>id3length</field-name>
             <field-name>id3bitrate</field-name>
             </load-group>
             <eager-load-group>all</eager-load-group>
             </load-groups>
             <query>
             <query-method>
             <method-name>findAll</method-name>
             <method-params>
             </method-params>
             </query-method>
             <jboss-ql>[CDATA[SELECT OBJECT(a) FROM minfo as a]]</jboss-ql>
            
             <read-ahead>
             <strategy>on-load</strategy>
             <page-size>4</page-size>
             <eager-load-group>all</eager-load-group>
             </read-ahead>
             </query>
            .
            .
            .
             <entity-command name="mysql-get-generated-keys">
             </entity-command>
            <!-- jboss 3.2 features -->
            <!-- optimistic locking does not express the exclusions needed -->
             </entity>
            
             </enterprise-beans>
            
            </jbosscmp-jdbc>
            


            Thanks again...!

            • 3. Re: cmp performance problem with getmethod
              smilidon

              p.s. i use jboss 3.2.5

              • 4. Re: cmp performance problem with getmethod
                aloubyansky

                Read the Optimized Loading chapter once again and pay attention to DTD and transactions.