|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ObjectCache
The ObjectCache
stores all Objects loaded by the
PersistenceBroker
from a DB.
When the PersistenceBroker tries to get an Object by its Primary key values
it first lookups the cache if the object has been already loaded and cached.
Using an ObjectCache has several advantages:
- it increases performance as it reduces DB lookups.
- it allows to perform circular lookups (as by crossreferenced objects)
that would result in non-terminating loops without such a cache. This will be internally handled by OJB, no
need to take care of this.
- it maintains the uniqueness of objects as any Db row will be mapped to
exactly one object.
This interface allows to have userdefined Cache implementations.
The ObjectCacheFactory is responsible for generating cache instances.
by default it uses the OJB ObjectCacheDefaultImpl
.
Note: Each PersistenceBroker
was
associated with its own ObjectCache
instance at creation
time.
ObjectCacheFactory
is responsible for creating ObjectCache
instances. To make the ObjectCache
implementation work, a
constructor with PersistenceBroker
and
Properties
as arguments or only PersistenceBroker
argument is needed.
Method Summary | |
---|---|
void |
cache(Identity oid,
java.lang.Object obj)
Used to cache objects by it's Identity . |
void |
clear()
Clear the cache. |
java.lang.Object |
lookup(Identity oid)
Lookup object with Identity 'oid' in cache. |
void |
remove(Identity oid)
Removes an Object from the cache. |
Method Detail |
---|
void cache(Identity oid, java.lang.Object obj)
Identity
.
oid
- Identity of the object to cache.obj
- The object to cache.java.lang.Object lookup(Identity oid)
oid
- Identity of the object to search for.
Identity
is found.void remove(Identity oid)
oid
- Identity of the object to be removed.void clear()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |