Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-dev] Eclipselink and Oracle Total Recall - Caching Problem

What version of EclipseLink are you using?  "eclipselink.maintain-cache" is only available as of 1.1 .  I have written a similar test case and this combination worked for me.

em.createNativeQuery("select * from EMPLOYEE_STUFF", Employee.class).setHint(QueryHints.MAINTAIN_CACHE, "false").setHint(QueryHints.READ_ONLY, "true").getResultList();

produced :

[Employee: 1 , bob, Employee: 1 , doug, Employee: 1 , marge]

--Gordon

Diogo Guerra wrote:
Hi Gordon,

Thanks for the quick answer. I tried that but I got the same result. My code is the following:

    public List<Table> getPrevHours(Long TableNumber, int hours) {
        try {
            Query q = em.createNativeQuery("SELECT * FROM Table VERSIONS BETWEEN TIMESTAMP(systimestamp - INTERVAL '1' HOUR) AND SYSTIMESTAMP WHERE PK = ?", Table.class);
            q.setHint("eclipselink.maintain-cache", "false");
            q.setHint("eclipselink.read-only", "true");
            q.setParameter(1, TableNumber);
            List<Table> temp = q.getResultList();
            for (Table b : temp) {
                System.out.println(b.getTableParam());
            }
            return temp;
        } catch (Exception e) {
            return null;
        }
    }


If I run the query directly into the database I got 3 records all with different values (except the pk). But when I run the code I got 3 records all equal. Any other Ideas? Do I need to configure something special in the Entity definition?

Cheers,
-----------------------
Diogo Guerra
Dei - FCTUC


On Tue, Mar 10, 2009 at 6:39 PM, Gordon Yorke <gordon.yorke@xxxxxxxxxx> wrote:
The issue is not exactly the cache.  TopLink interprets the results as the same instance because the PK is the same and only one instance of any object is allowed within the Persistence Context / Entity Manager.
You could try "eclipselink.maintain-cache" = "false" in combination with "eclipselink.read-only" = "true".  This should bypass the Persistence Context and the cache.
--Gordon


X-Rider wrote:
Hi,

I'm using oracle total recall and I'm having really big problems due the use
of caching.
For example I'm doing a query like:



Query q = em.createNativeQuery("select * from table versions between
timestamp(systimestamp - interval '1' day) and systimestamp where pk = 1",
Table.class);
q.setHint("eclipselink.cache-usage", "DoNotCheckCache");

List<Table> temp = q.getResultList();

But all the records are equal, because the PK is the same. Eclipselink is
using the caching I think. If I do it by a native query without specifying
the  entity class the values come good, but then I need to construct the
objects.

I've even tried to put in the entity definition:

@Entity
@Cache (type=CacheType.NONE)

But always get the samething.

Anyone knows how to disable the caching for only one query? Or even
globally?

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


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

Back to the top