2 Replies Latest reply on Jun 19, 2003 7:07 AM by mfrost

    findByPrimaryKey hits database each time

    mfrost

      I am trying to understand why my calls to findByPrimaryKey are hitting the database each time.

      I am using CMP version 2.x with local interfaces. I have even specified my entity bean as read-only, commit-option A but still it re-issues the SQL:

      <configuration-name>Standard CMP 2.x EntityBean with CI A</configuration-name>
      <read-only>true</read-only>

      Code extract:

      Context initial = new InitialContext();
      Object objref = initial.lookup("local/CompanyXmlRO");

      CompanyXmlHome home =
      (CompanyXmlHome)PortableRemoteObject.narrow(objref,CompanyXmlHome.class);

      CompanyXml companyXml = home.findByPrimaryKey(new Long(10));
      companyXml = home.findByPrimaryKey(new Long(10));

      Can anyone explain why this might be?

      Using the JMX-console I've noticed there are 3 "caches" specified all with values of zero:

      1. org.jboss.ejb.EntityContainer CacheSize = 0
      2. org.jboss.ejb.plugins.EntityInstancePool CurrentSize = 0
      3. org.jboss.ejb.plugins.InvalidableEntityInstanceCache CacheSize = 0

      Many thanks