Re: Performance for Finders

Vikram Naik <[email protected]>
Newsgroups gmane.comp.java.sun.ejb.general
Message-ID <[email protected]>
Re: Performance for FindersHello ,

Johan is right by saying  "Custom finders will always require a database roundtrip (most app servers) even if the resulting row already has a representation in the cache". 

As said in the specs for EJB 2.1 under  section "10.5.3 Container's View" 
"public <primary key type or collection> ejbFind<METHOD>(...);

.... The container invokes the ejbFind<METHOD> method on an instance when a client invokes a matching find<METHOD> method on the entity bean's home interface.
The container must pick an instance that is in he pooled state (i.e., the instance is not associated with any entity object identity) for the execution of the ejbFind<METHOD> method.
If there is no instance in the pooled state, the container creates one and calls he setEntityContext method on the instance before dispatching the finder method. ...... 

Before invoking the ejbFind<METHOD> method, the container must first synchronize the state of those entity bean instances by invoking the ejbStore method on them. 
This requirement does not apply to the ejbFindByPrimaryKey method..... "

This means there can be difference in performance between the customFinders and findByPrimaryKey methods 
As that the container has to/needs to sync the states of all the beans by invoking ejbStore method, which amounts to database roundtrip 

thanks & regards,
Vikram Naik
  ----- Original Message ----- 
  From: Johan Eltes 
  To: [email protected] 
  Sent: Wednesday, August 06, 2003 3:28 PM
  Subject: Re: Performance for Finders


  findByPrimayKey  allows the app server to pick the object from an entity cache without a roundtrip to the database. Custom finders will always require a database roundtrip (most app servers) even if the resulting row already has a representation in the cache. 

  /Johan

  Den 03-08-06 10.05, skrev "Vikram Naik" <[email protected]>:


    Hello All,

       Is there a performance difference between the findByPrimayKey and customFinders ? 

    Ofcourse the performance of the custom finders will depend on the query, but fot this case we can consider the query of the custom finders will be as simple as that of the findByPrimaryKey!!

    Please comment.

    TIA,
    Vikram Naik
    =========================================================================== To unsubscribe, send email to [email protected] and include in the body of the message "signoff EJB-INTEREST".  For general help, send email to [email protected] and include in the body of the message "help". 




  =========================================================================== To unsubscribe, send email to [email protected] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [email protected] and include in the body of the message "help". 

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[email protected] and include in the body of the message "help".
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.