Mantis - Resin
Viewing Issue Advanced Details
1012 minor always 03-23-06 15:54 04-04-06 16:19
ferg  
ferg  
high  
closed 3.0.18  
fixed  
none    
none 3.0.19  
0001012: findByPrimaryKey with cached data
(rep by Christian Amott)

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.


Notes
(0001011)
ferg   
04-04-06 16:19   
ejb/0aje