Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
EclipseLink/UserGuide/JPA/Basic JPA Development/Caching/Query Options
< EclipseLink | UserGuide | JPA | Basic JPA Development | Caching
Revision as of 11:39, 29 May 2012 by James.sutherland.oracle.com (Talk | contribs) (New page: {{EclipseLink_UserGuide |info=y |toc=y |eclipselink=y |eclipselinktype=JPA |api=y |apis= *[http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/config/QueryHints.html Quer...)
EclipseLink JPA
EclipseLink | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
Key API
Native API
Contents
Query Options and In-memory Querying
The EclipseLink query results cache allows the results of named queries to be cached, similar to how objects are cached.
Configuring Query Results Cache
The query results cache is configured through query hints.
Hint | Description | Default | Required? |
---|---|---|---|
eclipselink.query-results-cache | Enable query results cache for the named query. | no cached results | Required |
eclipselink.query-results-cache.size | Sets the fixed size of the query results cache for the named query. The size is the number of queries with unique parameters to cache. If the query has no parameters, a value of 1 should be used. | 100 | Optional |
eclipselink.query-results-cache.expiry | Sets the expiry time in milliseconds of the cached results. | no expiry | Optional |
eclipselink.query-results-cache.expiry-time-of-day | Configures the time of day expiry. Valid values are string time format, "HH:MM:SS". | no expiry | Optional |
eclipselink.query-results-cache.randomize-expiry | Set if the expiry time should be randomized by 10% of the set expiry time. This can be used to avoid a bottleneck on a fixed expiry time. | false | Optional |
eclipselink.query-results-cache.type | Set the cache type. Valid values are defined in the CacheType enum. Normally an LRU fixed sized CACHE is used, a FULL, WEAK or SOFT cache can also be used. | CACHE | Optional |
In-memory query example
Query query = em.createQuery("Select e from Employee e where e.firstName like :firstName and e.lastName like :lastName"); query.setParameter("firstName", "B%"); query.setParameter("lastName", "S%"); List<Employee> employees = query.getResultList();