Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0001003 [Resin] major always 03-20-06 16:12 04-04-06 16:20
Reporter nquery View Status public  
Assigned To ferg
Priority normal Resolution fixed  
Status closed   Product Version 3.0.18
Summary 0001003: findByPrimaryKey with cached data
Description If I do a findByPrimaryKey on a bean that has been previously cached by resin and the cache period has expired, then resin will not actually do a re-load/select or check to see if it exists anymore until one of it's fields is accessed. It is only when something is done with one of it's fields or via cmr that an amber/ejb exception is thrown if the object has been removed from the db.

Thus, the findByPrimaryKey method itself does not generate an ObjectNotFoundException if the object no longer exists and if the bean has been previously cached - but it will if it's the first time the key has been asked for and it's not cached.

I am assuming that this is a bug ... or is this intended behaviour?

eg. see attached .ejb file

            try {
                    symbol = symbolHome.findByPrimaryKey(symbolId);
                } catch (FinderException e) {
                    // if the object doesn't exist in the db then an objectnotfoundexception is only thrown *if* the bean specified by the key has not been cached previously by resin, *even if* the cache period has expired
                }

        String name = symbol.getLongName(); // if the symbol object no longer exists in the db and the cache period has expired, then this will cause an AmberObjectNotFoundException ....

it's obviously incorrect for the findByPrimaryKey to not throw an exception if the object does not exist after the cache period has expired ... i need to be able to trap this.

cheers
christian
Additional Information   <entity>
    <ejb-name>symbols</ejb-name>
    <local-home>com.quotemedia.lookup.ejb.SymbolHome</local-home>
    <local>com.quotemedia.lookup.ejb.Symbol</local>
    <ejb-class>com.quotemedia.lookup.ejb.SymbolBean</ejb-class>
    <persistence-type>Container</persistence-type>
    <reentrant>True</reentrant>
    
    <cache-size>300000</cache-size>
    <cache-timeout>5m</cache-timeout>

    <abstract-schema-name>symbol</abstract-schema-name>
    <sql-table>symbol</sql-table>

    <primkey-field>symbolId</primkey-field>
    <prim-key-class>java.lang.Long</prim-key-class>

    <cmp-field>
      <field-name>symbol</field-name>
      <sql-column>symbol</sql-column>
    </cmp-field>
    <cmp-field>
      <field-name>symbolId</field-name>
      <sql-column>symbolid</sql-column>
    </cmp-field>
    <cmp-field>
      <field-name>exchangeCode</field-name>
      <sql-column>excode</sql-column>
    </cmp-field>
   <cmp-field>
      <field-name>longName</field-name>
      <sql-column>name</sql-column>
    </cmp-field>
    <cmp-field>
      <field-name>shortName</field-name>
      <sql-column>shortname</sql-column>
    </cmp-field>
   <cmp-field>
      <field-name>marketId</field-name>
      <sql-column>marketid</sql-column>
    </cmp-field>
   <cmp-field>
      <field-name>expireDate</field-name>
      <sql-column>expire</sql-column>
    </cmp-field>

    <query>
      <query-method>
        <method-name>findAll</method-name>
      </query-method>
      <ejb-ql>SELECT object(s) from symbol s</ejb-ql>
    </query>
    <query>
      <query-method>
        <method-name>findBySymbol</method-name>
      </query-method>
      <ejb-ql>SELECT object(s) from symbol s where s.symbol=?1 and (s.expireDate is null or s.expireDate >= ?2)</ejb-ql>
    </query>
    <query>
      <query-method>
        <method-name>findByExchangeGroup</method-name>
        <method-params>
            <method-param>java.lang.String</method-param>
            <method-param>java.util.Date</method-param>
            <method-param>int</method-param>
            <method-param>int</method-param>
        </method-params>
      </query-method>
      <ejb-ql>SELECT object(s) from symbol s where s.exchange.exchangeGroup=?1 and (s.expireDate is null or s.expireDate >= ?2) order by s.symbol offset ?3 limit ?4</ejb-ql>
    </query>

    <query>
      <query-method>
        <method-name>findByExchangeGroup</method-name>
        <method-params>
            <method-param>java.lang.String</method-param>
            <method-param>java.util.Date</method-param>
        </method-params>
      </query-method>
      <ejb-ql>SELECT object(s) from symbol s where s.exchange.exchangeGroup=?1 and (s.expireDate is null or s.expireDate >= ?2) order by s.symbol</ejb-ql>
    </query>

    <query>
      <query-method>
        <method-name>ejbSelectOptionsInEntity</method-name>
      </query-method>
      <ejb-ql>SELECT OBJECT(o) FROM chain o WHERE o.rootSymbol.symbolId=?1 ORDER BY o.seq</ejb-ql>
    </query>
  </entity>
Attached Files

- Relationships

- Notes
(0001012)
ferg
04-04-06 16:20

ejb/0aje
 

- Issue History
Date Modified Username Field Change
03-20-06 16:12 nquery New Issue
04-04-06 16:20 ferg Note Added: 0001012
04-04-06 16:20 ferg Assigned To  => ferg
04-04-06 16:20 ferg Status new => closed
04-04-06 16:20 ferg Resolution open => fixed
04-04-06 16:20 ferg Fixed in Version  => 3.0.19


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
29 total queries executed.
26 unique queries executed.
Powered by Mantis Bugtracker