0 Replies Latest reply on Mar 20, 2002 9:30 AM by rikonen

    Entity bean handling is slow

    rikonen

      I'm trying to fetch some entity beans normally using findByXXX method. Everything works fine except that the finder works exteremely slowly. The problem only seems to appear with certain beans and somewhat randomly (on other pages there is virually no delay but on other pages the find takes almost a second).

      Also, after getting the entity beans, some getters (quite randomly again) block for several hunder milliseconds. For example, mybean.getId() sometimes takes 600 milliseconds but normally it takes 0 milliseconds.

      The code in my session bean looks like this:
      ---
      long startTime = System.currentTimeMillis();
      InitialContext ic = new InitialContext();
      Object objref = ic.lookup("package.MyBean");
      MyHome myHome = (MyHome)PortableRemoteObject.narrow(objref, MyHome.class);

      System.out.println("t1: " + (System.currentTimeMillis() - startTime));
      Collection c = myHome.findBySomefield(someId);
      System.out.println("t2: " + (System.currentTimeMillis() - startTime));
      ---

      The printout of the code above looks like this:
      ---
      [Default] t1: 16
      [DefaultDS] Resource 'org.jboss.pool.jdbc.xa.wrapper.XAResourceImpl@be1c9' enlisted for 'org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@4837cd'.
      [DefaultDS] Pool DefaultDS [1/1/10] gave out pooled object: org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@4837cd
      [Default] 1:SELECT id FROM sometable WHERE somefield=2
      [Default] t2: 703
      ---

      The find returns only about 20 matches so it certainly shouldn't take that long.

      The jaws.xml entry for this bean looks like this:
      ---

      <ejb-name>pakcage.MyBean</ejb-name>
      <table-name>sometable</table-name>
      <create-table>true</create-table>
      <remove-table>false</remove-table>
      <tuned-updates>true</tuned-updates>

      ---

      And the ejb-jar.xml entry is something like this:
      ---

      <display-name>MyBean</display-name>
      <ejb-name>package.MyBean</ejb-name>
      package.MyHome
      package.My
      <ejb-class>package.MyBean</ejb-class>
      <persistence-type>Container</persistence-type>
      False
      <cmp-field>
      ...
      </cmp-field>
      <prim-key-class>java.lang.Integer</prim-key-class>
      <primkey-field>id</primkey-field>

      ---

      I'm using JBoss version 2.4.3 (Tomcat 3.2.3). I've tested this with Hypersonic, MySQL and Postgres and the result has always been the same.

      Any ideas are appreciated,
      Rauli