Skip to content

Commit

Permalink
move Cache Interface to ch 3 with the other material on second-level …
Browse files Browse the repository at this point in the history
…cache
  • Loading branch information
gavinking authored and lukasj committed Dec 15, 2023
1 parent 8bcb55a commit 113c012
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 63 deletions.
63 changes: 63 additions & 0 deletions spec/src/main/asciidoc/ch03-entity-operations.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4275,6 +4275,69 @@ public enum CacheStoreMode {
}
----

==== Cache Interface [[a12124]]

The `Cache` interface provides basic
functionality over the persistence provider's second level cache, if
used.

[source,java]
----
package jakarta.persistence;
/**
* Interface used to interact with the second-level cache.
* If a cache is not in use, the methods of this interface have
* no effect, except for <code>contains</code>, which returns false.
*
* @since 2.0
*/
public interface Cache {
/**
* Whether the cache contains data for the given entity.
* @param cls entity class
* @param primaryKey primary key
* @return boolean indicating whether the entity is in the cache
*/
public boolean contains(Class cls, Object primaryKey);
/**
* Remove the data for the given entity from the cache.
* @param cls entity class
* @param primaryKey primary key
*/
public void evict(Class cls, Object primaryKey);
/**
* Remove the data for entities of the specified class (and its
* subclasses) from the cache.
* @param cls entity class
*/
public void evict(Class cls);
/**
* Clear the cache.
*/
public void evictAll();
/**
* Return an object of the specified type to allow access to the
* provider-specific API. If the provider's Cache
* implementation does not support the specified class, the
* PersistenceException is thrown.
* @param cls the class of the object to be returned. This is
* normally either the underlying Cache implementation
* class or an interface that it implements.
* @return an instance of the specified class
* @throws PersistenceException if the provider does not
* support the call
* @since 2.1
*/
public <T> T unwrap(Class<T> cls);
}
----

=== Query APIs [[a3125]]

The `Query` and `TypedQuery` APIs are used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1450,69 +1450,6 @@ provider must throw the `IllegalStateException`.
* When `EntityManager.clear` is invoked, the
provider must detach all managed entities.

=== Cache Interface [[a12124]]

The `Cache` interface provides basic
functionality over the persistence provider's second level cache, if
used.

[source,java]
----
package jakarta.persistence;
/**
* Interface used to interact with the second-level cache.
* If a cache is not in use, the methods of this interface have
* no effect, except for <code>contains</code>, which returns false.
*
* @since 2.0
*/
public interface Cache {
/**
* Whether the cache contains data for the given entity.
* @param cls entity class
* @param primaryKey primary key
* @return boolean indicating whether the entity is in the cache
*/
public boolean contains(Class cls, Object primaryKey);
/**
* Remove the data for the given entity from the cache.
* @param cls entity class
* @param primaryKey primary key
*/
public void evict(Class cls, Object primaryKey);
/**
* Remove the data for entities of the specified class (and its
* subclasses) from the cache.
* @param cls entity class
*/
public void evict(Class cls);
/**
* Clear the cache.
*/
public void evictAll();
/**
* Return an object of the specified type to allow access to the
* provider-specific API. If the provider's Cache
* implementation does not support the specified class, the
* PersistenceException is thrown.
* @param cls the class of the object to be returned. This is
* normally either the underlying Cache implementation
* class or an interface that it implements.
* @return an instance of the specified class
* @throws PersistenceException if the provider does not
* support the call
* @since 2.1
*/
public <T> T unwrap(Class<T> cls);
}
----

=== PersistenceUnitUtil Interface [[a12177]]

The `PersistenceUnitUtil` interface provides
Expand Down

0 comments on commit 113c012

Please sign in to comment.