Package one.microstream.storage.types
Class Database.Default
java.lang.Object
one.microstream.storage.types.Database.Default
- All Implemented Interfaces:
PersistenceStoring,Persister,ObjectSwizzling,Database,DatabasePart
- Enclosing interface:
- Database
public static final class Database.Default extends Object implements Database
-
Nested Class Summary
Nested classes/interfaces inherited from interface one.microstream.storage.types.Database
Database.Default -
Method Summary
Modifier and Type Method Description StorercreateEagerStorer()Creates a newStorerinstance with eager storing behavior.StorercreateLazyStorer()Creates a newStorerinstance with lazy storing behavior.StorercreateStorer()Creates a newStorerinstance with default storing behavior.StringdatabaseName()Returns the identifying name of theDatabasethis part belongs to.ObjectgetObject(long objectId)Retrieves the instance associated with the passed objectId.StorageManagerguaranteeActiveStorage()DatabaseguaranteeNoActiveStorage()StorageManagersetStorage(StorageManager storage)StorageManagerstorage()longstore(Object instance)Stores the passed instance in any case and all referenced instances of persistable references recursively, but stores referenced instances only if they are newly encountered (e.g.voidstoreAll(Iterable<?> instances)Convenience method toPersistenceStoring.store(Object)all instances of anIterabletype, usually a collection.
The passed instance itself is NOT stored.
Note that this method does not return an array of objectIds, since the amount of instances supplied by the passedIterablecannot be known until after all instances have been stored and the memory and performance overhead to collect them dynamically would not be worth it in most cases since the returned array is hardly ever needed.long[]storeAll(Object... instances)Convenience method toPersistenceStoring.store(Object)multiple instances.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface one.microstream.storage.types.Database
hasStorage, toIdentifyingString
-
Method Details
-
databaseName
Description copied from interface:DatabasePartReturns the identifying name of theDatabasethis part belongs to.- Specified by:
databaseNamein interfaceDatabasePart- Returns:
- the identifying name of the
Database.
-
storage
-
guaranteeNoActiveStorage
- Specified by:
guaranteeNoActiveStoragein interfaceDatabase
-
guaranteeActiveStorage
- Specified by:
guaranteeActiveStoragein interfaceDatabase
-
setStorage
- Specified by:
setStoragein interfaceDatabase
-
getObject
Description copied from interface:PersisterRetrieves the instance associated with the passed objectId. Retrieving means guaranteeing that the associated instance is returned. If it does not yet exist, it will be created from persisted data, including all non-lazily referenced objects it is connected to.- Specified by:
getObjectin interfaceObjectSwizzling- Specified by:
getObjectin interfacePersister- Parameters:
objectId- the objectId defining which instance to return.- Returns:
- the instance associated with the passed objectId.
-
store
Description copied from interface:PersisterStores the passed instance in any case and all referenced instances of persistable references recursively, but stores referenced instances only if they are newly encountered (e.g. don't have an id associated with them in the object registry, yet and are therefore required to be handled). This is useful for the common case of just storing an updated instance and potentially newly created instances along with it while skipping all existing (and normally unchanged) referenced instances.- Specified by:
storein interfacePersistenceStoring- Specified by:
storein interfacePersister- Parameters:
instance- the root instance of the subgraph of required instances to be stored.- Returns:
- the object id representing the passed instance.
-
storeAll
Description copied from interface:PersisterConvenience method toPersistenceStoring.store(Object)multiple instances. The passed array (maybe implicitely created by the compiler) itself is NOT stored.- Specified by:
storeAllin interfacePersistenceStoring- Specified by:
storeAllin interfacePersister- Parameters:
instances- multiple root instances of the subgraphs of required instances to be stored.- Returns:
- an array containing the object ids representing the passed instances.
-
storeAll
Description copied from interface:PersisterConvenience method toPersistenceStoring.store(Object)all instances of anIterabletype, usually a collection.
The passed instance itself is NOT stored.
Note that this method does not return an array of objectIds, since the amount of instances supplied by the passedIterablecannot be known until after all instances have been stored and the memory and performance overhead to collect them dynamically would not be worth it in most cases since the returned array is hardly ever needed. If it should be needed, the desired behavior can be easily achieved with a tiny custom-made utility method.- Specified by:
storeAllin interfacePersistenceStoring- Specified by:
storeAllin interfacePersister- Parameters:
instances- multiple root instances of the subgraphs of required instances to be stored.
-
createLazyStorer
Description copied from interface:PersisterCreates a newStorerinstance with lazy storing behavior. This means an entity instance encountered while traversing the entity graph is only stored if it is not yet known to the persistence context, i.e. does not have an objectId associated with it in the persistence context'sPersistenceObjectRegistry.- Specified by:
createLazyStorerin interfacePersister- Returns:
- the newly created
Storerinstance.
-
createStorer
Description copied from interface:PersisterCreates a newStorerinstance with default storing behavior. The default is lazy storing. SeePersister.createLazyStorer().- Specified by:
createStorerin interfacePersister- Returns:
- the newly created
Storerinstance.
-
createEagerStorer
Description copied from interface:PersisterCreates a newStorerinstance with eager storing behavior. This means an entity instance encountered while traversing the entity graph is always stored, regardless of if it is already known to the persistence context or not, i.e. does have an objectId associated with it in the persistence context'sPersistenceObjectRegistry.Note: Eager storing is a dangerous behavior since - depending on the entity graph's referential layout - it can cause the whole entity graph present in the heap to be stored. Therefore, it is stronly advised to instead use lazy storing logic (see
Persister.createLazyStorer()) or some other kind of limiting storing logic.- Specified by:
createEagerStorerin interfacePersister- Returns:
- the newly created
Storerinstance.
-