= Caching

:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


By default the EclipseLink implementation of JPA enables a shared cache to cache objects read from the database and avoid repeated database access.
If the database is changed directly by another application or server, the objects in the shared cache will be stale.

To disable this globally, use:

[source]
.application.properties
----
eclipselink.cache.shared.default=false
----

For more information on this topic, see:

* link:https://wiki.eclipse.org/EclipseLink/FAQ/How_to_disable_the_shared_cache%3F[EclipseLink FAQ: how to disable the shared cache]

* link:https://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Caching[EclipseLink User Guide: Caching]

* link:https://wiki.eclipse.org/EclipseLink/Examples/JPA/Caching[EclipseLink Examples: Caching]
