| java.lang.Object com.sleepycat.persist.EntityStore
EntityStore | public class EntityStore (Code) | | |
Constructor Summary | |
public | EntityStore(Environment env, String storeName, StoreConfig config) Opens an entity store in a given environment.
Parameters: env - an open Berkeley DB Environment. Parameters: storeName - the name of the entity store within the givenenvironment. |
Method Summary | |
public void | close() Closes all databases and sequences that were opened via this store. | public void | closeClass(Class entityClass) Closes the primary and secondary databases for the given entity class
that were opened via this store. | void | dumpCatalog() Only public for debugging. | public EvolveStats | evolve(EvolveConfig config) Performs conversion of unevolved objects in order to reduce lazy
conversion overhead. | public StoreConfig | getConfig() Returns a copy of the entity store configuration. | public Environment | getEnvironment() Returns the environment associated with this store. | public EntityModel | getModel() Returns the current entity model for this store. | public Mutations | getMutations() Returns the set of mutations that were configured when the store was
opened, or if none were configured, the set of mutations that were
configured and stored previously. | public DatabaseConfig | getPrimaryConfig(Class entityClass) Returns the default primary database Berkeley DB engine API
configuration for an entity class.
The returned configuration is as follows. | public PrimaryIndex<PK, E> | getPrimaryIndex(Class<PK> primaryKeyClass, Class<E> entityClass) Returns the primary index for a given entity class, opening it if
necessary.
If they are not already open, the primary and secondary databases for
the entity class are created/opened together in a single internal
transaction. | public SecondaryConfig | getSecondaryConfig(Class entityClass, String keyName) Returns the default secondary database Berkeley DB engine API
configuration for an entity class and key name.
The returned configuration is as follows. | public SecondaryIndex<SK, PK, E> | getSecondaryIndex(PrimaryIndex<PK, E> primaryIndex, Class<SK> keyClass, String keyName) Returns a secondary index for a given primary index and secondary key,
opening it if necessary.
NOTE: If the secondary key field is declared in a subclass
of the entity class, use
EntityStore.getSubclassIndex instead.
If a
SecondaryKey.relatedEntity is used and the primary index
for the related entity is not already open, it will be opened by this
method. | public Sequence | getSequence(String name) Returns a named sequence for using Berkeley DB engine API directly,
opening it if necessary.
Parameters: name - the sequence name, which is normally defined using thePrimaryKey.sequence annotation property. | public SequenceConfig | getSequenceConfig(String name) Returns the default Berkeley DB engine API configuration for a named key
sequence.
The returned configuration is as follows. | public String | getStoreName() Returns the name of this store. | public static Set<String> | getStoreNames(Environment env) Returns the names of all entity stores in the given environment.
the store names. | public SecondaryIndex<SK, PK, E2> | getSubclassIndex(PrimaryIndex<PK, E1> primaryIndex, Class<E2> entitySubclass, Class<SK> keyClass, String keyName) Returns a secondary index for a secondary key in an entity subclass,
opening it if necessary.
If a
SecondaryKey.relatedEntity is used and the primary index
for the related entity is not already open, it will be opened by this
method. | public void | setPrimaryConfig(Class entityClass, DatabaseConfig config) Configures the primary database for an entity class using the Berkeley
DB engine API.
To be compatible with the entity model and the Direct Persistence
Layer, the configuration should be retrieved using
EntityStore.getPrimaryConfig getPrimaryConfig , modified, and then passed to this
method. | public void | setSecondaryConfig(Class entityClass, String keyName, SecondaryConfig config) Configures a secondary database for an entity class and key name using
the Berkeley DB engine API.
To be compatible with the entity model and the Direct Persistence
Layer, the configuration should be retrieved using
EntityStore.getSecondaryConfig getSecondaryConfig , modified, and then passed to
this method. | public void | setSequenceConfig(String name, SequenceConfig config) Configures a named key sequence using the Berkeley DB engine API. | public void | sync() Flushes each modified index to disk that was opened in deferred-write
mode.
All indexes are opened in deferred-write mode if true was passed to
StoreConfig.setDeferredWrite for the store.
Alternatively, individual databases may be configured for deferred
write using
DatabaseConfig.setDeferredWrite along with
EntityStore.getPrimaryConfig and
EntityStore.setPrimaryConfig . | public void | truncateClass(Class entityClass) Deletes all instances of this entity class and its (non-entity)
subclasses.
This is the equivalent of
Environment.truncateDatabaseEnvironment.truncateDatabase . | public void | truncateClass(Transaction txn, Class entityClass) Deletes all instances of this entity class and its (non-entity)
subclasses.
This is the equivalent of
Environment.truncateDatabaseEnvironment.truncateDatabase . |
EntityStore | public EntityStore(Environment env, String storeName, StoreConfig config) throws DatabaseException, IncompatibleClassException(Code) | | Opens an entity store in a given environment.
Parameters: env - an open Berkeley DB Environment. Parameters: storeName - the name of the entity store within the givenenvironment. An empty string is allowed. Named stores may be used todistinguish multiple sets of persistent entities for the same entityclasses in a single environment. Underlying database names are prefixedwith the store name. Parameters: config - the entity store configuration, or null to use defaultconfiguration properties. throws: IncompatibleClassException - if an incompatible class change hasbeen made and mutations are not configured for handling the change. Seecom.sleepycat.persist.evolve Class Evolution for moreinformation. |
close | public void close() throws DatabaseException(Code) | | Closes all databases and sequences that were opened via this store. The
caller must ensure that no databases opened via this store are in use.
|
closeClass | public void closeClass(Class entityClass) throws DatabaseException(Code) | | Closes the primary and secondary databases for the given entity class
that were opened via this store. The caller must ensure that the
primary and secondary indices obtained from this store are no longer in
use.
Parameters: entityClass - the entity class whose databases are to be closed. |
dumpCatalog | void dumpCatalog()(Code) | | Only public for debugging.
|
evolve | public EvolveStats evolve(EvolveConfig config) throws DatabaseException(Code) | | Performs conversion of unevolved objects in order to reduce lazy
conversion overhead. Evolution may be performed concurrently with
normal access to the store.
Conversion is performed one entity class at a time. An entity class
is converted only if it has
Mutations associated with it via
StoreConfig.setMutations StoreConfig.setMutations .
Conversion of an entity class is performed by reading each entity,
converting it if necessary, and updating it if conversion was performed.
When all instances of an entity class are converted, references to the
appropriate
Mutations are deleted. Therefore, if this method is
called twice successfully without changing class definitions, the second
call will do nothing.
See Also: com.sleepycat.persist.evolve See Also: Class Evolution |
getConfig | public StoreConfig getConfig()(Code) | | Returns a copy of the entity store configuration.
the config. |
getEnvironment | public Environment getEnvironment()(Code) | | Returns the environment associated with this store.
the environment. |
getModel | public EntityModel getModel()(Code) | | Returns the current entity model for this store. The current model is
derived from the configured entity model and the live entity class
definitions.
the model. |
getMutations | public Mutations getMutations()(Code) | | Returns the set of mutations that were configured when the store was
opened, or if none were configured, the set of mutations that were
configured and stored previously.
the mutations. |
getPrimaryConfig | public DatabaseConfig getPrimaryConfig(Class entityClass)(Code) | | Returns the default primary database Berkeley DB engine API
configuration for an entity class.
The returned configuration is as follows. All other properties have
default values.
Parameters: entityClass - the entity class identifying the primary database. the default configuration for the given entity class. |
getPrimaryIndex | public PrimaryIndex<PK, E> getPrimaryIndex(Class<PK> primaryKeyClass, Class<E> entityClass) throws DatabaseException(Code) | | Returns the primary index for a given entity class, opening it if
necessary.
If they are not already open, the primary and secondary databases for
the entity class are created/opened together in a single internal
transaction. When the secondary indices are opened, that can cascade to
open other related primary indices.
Parameters: primaryKeyClass - the class of the entity's primary key field, orthe corresponding primitive wrapper class if the primary key field typeis a primitive. Parameters: entityClass - the entity class for which to open the primary index. the primary index. throws: IllegalArgumentException - if the entity class or classesreferenced by it are not persistent, or the primary key class does notmatch the entity's primary key field, or if metadata for the entity orprimary key is invalid. |
getSecondaryConfig | public SecondaryConfig getSecondaryConfig(Class entityClass, String keyName)(Code) | | Returns the default secondary database Berkeley DB engine API
configuration for an entity class and key name.
The returned configuration is as follows. All other properties have
default values.
Parameters: entityClass - the entity class containing the given secondary keyname. Parameters: keyName - the name of the secondary key field, or the SecondaryKey.name if this name annotation property was specified. the default configuration for the given secondary key. |
getSecondaryIndex | public SecondaryIndex<SK, PK, E> getSecondaryIndex(PrimaryIndex<PK, E> primaryIndex, Class<SK> keyClass, String keyName) throws DatabaseException(Code) | | Returns a secondary index for a given primary index and secondary key,
opening it if necessary.
NOTE: If the secondary key field is declared in a subclass
of the entity class, use
EntityStore.getSubclassIndex instead.
If a
SecondaryKey.relatedEntity is used and the primary index
for the related entity is not already open, it will be opened by this
method. That will, in turn, open its secondary indices, which can
casade to open other primary indices.
Parameters: primaryIndex - the primary index associated with the returnedsecondary index. The entity class of the primary index, or one of itssuperclasses, must contain a secondary key with the given secondary keyclass and key name. Parameters: keyClass - the class of the secondary key field, or thecorresponding primitive wrapper class if the secondary key field type isa primitive. Parameters: keyName - the name of the secondary key field, or the SecondaryKey.name if this name annotation property was specified. the secondary index. throws: IllegalArgumentException - if the entity class or one of itssuperclasses does not contain a key field of the given key class and keyname, or if the metadata for the secondary key is invalid. |
getSequence | public Sequence getSequence(String name) throws DatabaseException(Code) | | Returns a named sequence for using Berkeley DB engine API directly,
opening it if necessary.
Parameters: name - the sequence name, which is normally defined using thePrimaryKey.sequence annotation property. the open sequence for the given sequence name. |
getSequenceConfig | public SequenceConfig getSequenceConfig(String name)(Code) | | Returns the default Berkeley DB engine API configuration for a named key
sequence.
The returned configuration is as follows. All other properties have
default values.
Parameters: name - the sequence name, which is normally defined using thePrimaryKey.sequence annotation property. the default configuration for the given sequence name. |
getStoreName | public String getStoreName()(Code) | | Returns the name of this store.
the name. |
getStoreNames | public static Set<String> getStoreNames(Environment env) throws DatabaseException(Code) | | Returns the names of all entity stores in the given environment.
the store names. An empty set is returned if no stores arepresent. |
getSubclassIndex | public SecondaryIndex<SK, PK, E2> getSubclassIndex(PrimaryIndex<PK, E1> primaryIndex, Class<E2> entitySubclass, Class<SK> keyClass, String keyName) throws DatabaseException(Code) | | Returns a secondary index for a secondary key in an entity subclass,
opening it if necessary.
If a
SecondaryKey.relatedEntity is used and the primary index
for the related entity is not already open, it will be opened by this
method. That will, in turn, open its secondary indices, which can
casade to open other primary indices.
Parameters: primaryIndex - the primary index associated with the returnedsecondary index. The entity class of the primary index, or one of itssuperclasses, must contain a secondary key with the given secondary keyclass and key name. Parameters: entitySubclass - a subclass of the entity class for the primaryindex. The entity subclass must contain a secondary key with the givensecondary key class and key name. Parameters: keyClass - the class of the secondary key field, or thecorresponding primitive wrapper class if the secondary key field type isa primitive. Parameters: keyName - the name of the secondary key field, or the SecondaryKey.name if this name annotation property was specified. the secondary index. throws: IllegalArgumentException - if the given entity subclass does notcontain a key field of the given key class and key name, or if themetadata for the secondary key is invalid. |
setPrimaryConfig | public void setPrimaryConfig(Class entityClass, DatabaseConfig config)(Code) | | Configures the primary database for an entity class using the Berkeley
DB engine API.
To be compatible with the entity model and the Direct Persistence
Layer, the configuration should be retrieved using
EntityStore.getPrimaryConfig getPrimaryConfig , modified, and then passed to this
method. The following configuration properties may not be changed:
Parameters: entityClass - the entity class identifying the primary database. Parameters: config - the configuration to use for the given entity class. throws: IllegalArgumentException - if the configuration is incompatiblewith the entity model or the Direct Persistence Layer. throws: IllegalStateException - if the database has already been opened. |
setSecondaryConfig | public void setSecondaryConfig(Class entityClass, String keyName, SecondaryConfig config)(Code) | | Configures a secondary database for an entity class and key name using
the Berkeley DB engine API.
To be compatible with the entity model and the Direct Persistence
Layer, the configuration should be retrieved using
EntityStore.getSecondaryConfig getSecondaryConfig , modified, and then passed to
this method. The following configuration properties may not be
changed:
Parameters: entityClass - the entity class containing the given secondary keyname. Parameters: keyName - the name of the secondary key field, or the SecondaryKey.name if this name annotation property was specified. Parameters: config - the configuration to use for the given secondary key. throws: IllegalArgumentException - if the configuration is incompatiblewith the entity model or the Direct Persistence Layer. throws: IllegalStateException - if the database has already been opened. |
setSequenceConfig | public void setSequenceConfig(String name, SequenceConfig config)(Code) | | Configures a named key sequence using the Berkeley DB engine API.
To be compatible with the entity model and the Direct Persistence
Layer, the configuration should be retrieved using
EntityStore.getSequenceConfig getSequenceConfig , modified, and then passed to this
method.
If the range is changed to include the value zero, see
PrimaryKey for restrictions.
Parameters: name - the sequence name, which is normally defined using thePrimaryKey.sequence annotation property. Parameters: config - the configuration to use for the given sequence name. throws: IllegalArgumentException - if the configuration is incompatiblewith the entity model or the Direct Persistence Layer. throws: IllegalStateException - if the sequence has already been opened. |
sync | public void sync() throws DatabaseException(Code) | | Flushes each modified index to disk that was opened in deferred-write
mode.
All indexes are opened in deferred-write mode if true was passed to
StoreConfig.setDeferredWrite for the store.
Alternatively, individual databases may be configured for deferred
write using
DatabaseConfig.setDeferredWrite along with
EntityStore.getPrimaryConfig and
EntityStore.setPrimaryConfig . Caution should be used
when configuring only some databases for deferred-write, since durability
will be different for these databases than for other databases in the
same store.
This method is functionally equivalent to calling
Database.sync for each deferred-write index Database that is open for
this store. However, while
Database.sync flushes the log to disk
each time it is called, this method flushes the log only once after
syncing all databases; this method therefore causes less I/O than calling
Database.sync multiple times.
Instead of calling this method,
Environment.sync may be used.
The difference is that this method will only flush the databases for this
store, while
Environment.sync will sync all deferred-write
databases currently open for the environment and will also perform a full
checkpoint. This method is therefore less expensive than a full sync of
the environment.
|
truncateClass | public void truncateClass(Class entityClass) throws DatabaseException(Code) | | Deletes all instances of this entity class and its (non-entity)
subclasses.
This is the equivalent of
Environment.truncateDatabaseEnvironment.truncateDatabase . The primary and secondary databases
associated with the entity class must not be open except by this store,
since database truncation is only possible when the database is not
open. The databases to be truncated will be closed before performing
this operation, if they were previously opened by this store.
Auto-commit is used implicitly if the store is transactional.
Parameters: entityClass - the entity class whose instances are to be deleted. |
truncateClass | public void truncateClass(Transaction txn, Class entityClass) throws DatabaseException(Code) | | Deletes all instances of this entity class and its (non-entity)
subclasses.
This is the equivalent of
Environment.truncateDatabaseEnvironment.truncateDatabase . The primary and secondary databases
associated with the entity class must not be open except by this store,
since database truncation is only possible when the database is not
open. The databases to be truncated will be closed before performing
this operation, if they were previously opened by this store.
Parameters: txn - the transaction used to protect this operation, null to useauto-commit, or null if the store is non-transactional. Parameters: entityClass - the entity class whose instances are to be deleted. |
|
|