Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Cache hit

Sorry...  accidentally hit send too early.

Here's the info about the refresh hint:

http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Refresh

I apologize for giving you information that solves a more complex problem than the one you are encountering in my initial response. The cache usage setting relates to how EclipseLink will determine whether an object exists or not, rather than a simple refresh.

-Tom

Tom Ware wrote:
Have you tried entityManager.refresh(object) that will guarantee SQL goes to the DB?

The refresh hint on your query will also likely solve your issue:


If that solves you

khaskett wrote:
I changed the code for a find to be this -
<code>
            final String queryString = "select model from CpTransaction
model where model.transactionId = :propertyValue";
            final Query query = em.createQuery(queryString);
            query.setParameter("propertyValue", id);
            query.setHint(QueryHints.CACHE_USAGE,
CacheUsage.DoNotCheckCache);
            return (CpTransaction) query.getSingleResult();
</code>

And now I see this call in the logs -

[5/20/09 10:34:50:203 CDT] 0000003e SystemOut     O [EL Fine]: 2009-05-20
10:34:50.203--ServerSession(421796132)--Connection(1967945036)--Thread(Thread[WebContainer
: 4,5,main])--SELECT TRANSACTION_ID, PREMIUM_ACTUAL, PREMIUM_NET,
AUDIT_REPORT, REINSURANCE_TYPE, TRANSITION_YEAR, INSURED_EMAIL,
CREATION_DATE, PREVIOUS_POLICY_NUMBER, PREMIUM_TARGET, COMPANY_CODE,
BILL_CHANGE, DELETION_DATE, BILL_TYPE_RENEWAL, LOCK_SESSION,
TRANSACTION_STATUS, DEC_IND, PROGRAM_TYPE, PRINT_NOTICE, PROCESSING_DATE,
INSURED_SUPPLEMENTARY_TYPE, TRANSACTION_UW, SETUP_DATE, MAIL_TYPE,
EXCLUDE_PKG_DISC, REASON_CODE, PT_EMPLOYEE_COUNT, DOC_MGMT_FLAG,
BILL_PLAN_RENEWAL, SHORT_TERM_FACTOR, RATE_EFFECTIVE_DATE, PCT_TERM,
ACORD_FLAG, INSURED_SUPPLEMENTARY_NAME, LOCK_EDITOR, BILL_PLAN,
EMPLOYEE_COUNT, TRANSACTION_FORMAT, BILL_ACCOUNT, TRANSACTION_FLAG,
RELATED_POLICY_NUMBER, PREMIUM_PREVIOUS, INSURED_FAX, REINSURANCE_COST,
RATE_LEVEL, OOS_DATA, PREMIUM_WAIVED_IND, TRANSACTION_DESC,
TRANSACTION_LABEL, RATING_FLAG, MODIFICATION_DATE, PRIMARY_STATE,
POLICY_NUMBER, INSURED_PHONE, PRODUCER, PREMIUM_MIN, TRANSACTION_TYPE,
PARENT_TRANSACTION_ID, CONTACT_PHONE, BILL_TYPE, BILL_TO_RENEWAL,
APPROVAL_INITIALS, EFFECTIVE_DATE, BILL_TO, PREMIUM_RECALC_MIN_IND,
RENEWAL_TYPE, ACCOUNT_NUM, SUSPENSE_NUMBER, SHORT_TERM_INDICATOR,
INSURED_NAME, SUSPENSE_AMT, BUSINESS_TYPE_DETAIL, CONTACT_NAME, LOCK_OWNER,
POLICY_TYPE, BUSINESS_TYPE, BUSINESS_DESCRIPTION, EXPIRATION_DATE,
PREMIUM_WAIVED, INSURED_FEIN, REASON_DESC, CONTRACT_NUMBER, CHANGE_DATE,
RATE_TABLE_DATE, DENY_FLAG, REINSURANCE_COMPANY, YRS_BUS, AGENCY_EFT,
AGT_RESET, AUDIT_TYPE, POLICY_LOB, PREMIUM_MEET_MIN, AUDIT_NAME,
INSURED_MAILING_NAME, BUSINESS_PHONE, POLICY_PMA, ACTION_CODE, INSURED_CITY,
INSURED_COUNTY, INSURED_ADDRESS_2, INSURED_ADDRESS_1, INSURED_STATE,
INSURED_POSTAL_CODE FROM CP_TRANSACTION WHERE (TRANSACTION_ID = CAST (? AS
BIGINT ))
    bind => [32967]

But I am getting an old copy of the data. I can use a tool like SQLSquirrel and I see that it has data that is not reflected in what is being returned
by the find.

How is that possible?


tware wrote:
Although the following are not specifically for "find" operations, they
may be helpful.

First, try writing a query that makes use of caching hints:

http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Cache_Usage

For configuring on a more broad scale there are some entity-level config
options here:

http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#How_to_Use_the_.40Cache_Annotation



khaskett wrote:
Is there a way on a find, to know if the value returned was from the
cache or
was a DB read?  Or is there a way to always force a read from the
database
on a find?

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users






Back to the top