public abstract class InMemoryDocumentSessionOperations extends Object implements CleanCloseable
Modifier and Type | Field and Description |
---|---|
protected String |
_databaseName |
protected String |
dbName |
protected Set<Object> |
deletedEntities |
protected Map<Object,DocumentMetadata> |
entitiesAndMetadata |
protected Map<String,Object> |
entitiesByKey |
EntityToJson |
entityToJson |
protected boolean |
generateDocumentKeysOnStore |
protected Map<String,JsonDocument> |
includedDocumentsByKey |
protected Set<String> |
knownMissingIds |
protected static ILog |
log |
protected Map<ILazyOperation,Action1<Object>> |
onEvaluateLazy |
protected List<ILazyOperation> |
pendingLazyOperations |
protected DocumentSessionListeners |
theListeners |
Modifier | Constructor and Description |
---|---|
protected |
InMemoryDocumentSessionOperations(String dbName,
DocumentStoreBase documentStore,
DocumentSessionListeners listeners,
UUID id)
Initializes a new instance of the
InMemoryDocumentSessionOperations class. |
Modifier and Type | Method and Description |
---|---|
protected void |
assertNoNonUniqueInstance(Object entity,
String id) |
boolean |
checkIfIdAlreadyIncluded(String[] ids,
Tuple<String,Class<?>>[] includes) |
void |
clear()
Clears this instance.
|
void |
close()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
Object |
convertToEntity(Class<?> entityType,
String id,
RavenJObject documentFound,
RavenJObject metadata,
boolean isStreaming)
Converts the json document to an entity.
|
String |
createDynamicIndexName(Class clazz) |
protected ICommandData |
createPutEntityCommand(Object entity,
DocumentMetadata documentMetadata)
Creates the put entity command.
|
void |
defer(ICommandData... commands)
Defer commands to be executed on saveChanges()
|
<T> void |
delete(Class<T> clazz,
Number id)
Marks the specified entity for deletion.
|
<T> void |
delete(Class<T> clazz,
UUID id)
Marks the specified entity for deletion.
|
void |
delete(String id)
Marks the specified entity for deletion.
|
<T> void |
delete(T entity)
Marks the specified entity for deletion.
|
static void |
ensureNotReadVetoed(RavenJObject metadata) |
protected boolean |
entityChanged(Object entity,
DocumentMetadata documentMetadata) |
protected boolean |
entityChanged(Object entity,
DocumentMetadata documentMetadata,
Map<String,List<DocumentsChanges>> changes)
Determines if the entity have changed.
|
<T> void |
evict(T entity)
Evicts the specified entity from the session.
|
void |
explicitlyVersion(Object entity)
Version this entity when it is saved.
|
protected abstract String |
generateKey(Object entity) |
DocumentConvention |
getConventions()
Gets the conventions used by this session
This instance is shared among all sessions, changes to the
DocumentConvention should be done
via the IDocumentStore instance, not on a single session. |
String |
getDatabaseName() |
String |
getDocumentId(Object instance)
Gets the document id.
|
protected <T> DocumentMetadata |
getDocumentMetadataValue(T instance,
Reference<String> idHolder,
JsonDocument jsonDocument) |
IDocumentStore |
getDocumentStore() |
EntityToJson |
getEntityToJson() |
<T> Etag |
getEtagFor(T instance)
Gets the ETag for the specified entity.
|
Map<String,Object> |
getExternalState() |
GenerateEntityIdOnTheClient |
getGenerateEntityIdOnTheClient() |
UUID |
getId() |
protected abstract JsonDocument |
getJsonDocument(String documentKey)
Get the json document by key from the store
|
DocumentSessionListeners |
getListeners() |
int |
getMaxNumberOfRequestsPerSession()
Gets the max number of requests per session.
|
<T> RavenJObject |
getMetadataFor(T instance)
Gets the metadata for the specified entity.
|
Long |
getNonAuthoritativeInformationTimeout()
Gets the timeout to wait for authoritative information if encountered non authoritative document.
|
int |
getNumberOfEntitiesInUnitOfWork()
Gets the number of entities held in memory to manage Unit of Work
|
int |
getNumberOfRequests() |
String |
getStoreIdentifier()
Gets the store identifier for this session.
|
protected void |
handleInternalMetadata(RavenJObject result) |
boolean |
hasChanged(Object entity)
Determines whether the specified entity has changed.
|
boolean |
hasChanges()
Gets a value indicating whether any of the entities tracked by the session has changes.
|
int |
hashCode() |
void |
ignoreChangesFor(Object entity) |
void |
incrementRequestCount() |
boolean |
isAllowNonAuthoritativeInformation()
Gets a value indicating whether non authoritative information is allowed.
|
boolean |
isDeleted(String id)
Returns whatever a document with the specified id is deleted
or known to be missing
|
boolean |
isLoaded(String id)
Returns whatever a document with the specified id is loaded in the
current session
|
boolean |
isUseOptimisticConcurrency()
Gets a value indicating whether the session should use optimistic concurrency.
|
protected void |
logBatch(SaveChangesData data) |
void |
markReadOnly(Object entity)
Mark the entity as read only, change tracking won't apply
to such an entity.
|
protected SaveChangesData |
prepareForSaveChanges()
Prepares for save changes.
|
Object |
projectionToInstance(RavenJObject y,
Class<?> type) |
<T> void |
refreshInternal(T entity,
JsonDocument jsonDocument,
DocumentMetadata value) |
void |
registerMissing(String id) |
void |
registerMissingIncludes(Collection<RavenJObject> results,
Collection<String> includes) |
protected void |
rememberEntityForDocumentKeyGeneration(Object entity) |
void |
setAllowNonAuthoritativeInformation(boolean allowNonAuthoritativeInformation)
Sets a value indicating whether non authoritative information is allowed.
|
void |
setDatabaseName(String databaseName) |
void |
setMaxNumberOfRequestsPerSession(int maxNumberOfRequestsPerSession)
Sets the max number of requests per session.
|
void |
setNonAuthoritativeInformationTimeout(Long nonAuthoritativeInformationTimeout)
Sets the timeout to wait for authoritative information if encountered non authoritative document.
|
void |
setUseOptimisticConcurrency(boolean useOptimisticConcurrency)
Sets a value indicating whether the session should use optimistic concurrency.
|
void |
store(Object entity)
Stores the specified entity in the session.
|
void |
store(Object entity,
Etag etag)
Stores the specified entity in the session.
|
void |
store(Object entity,
Etag etag,
String id)
Stores the specified entity in the session, explicitly specifying its Id.
|
void |
store(Object entity,
String id)
Stores the specified entity in the session, explicitly specifying its Id.
|
protected void |
storeEntityInUnitOfWork(String id,
Object entity,
Etag etag,
RavenJObject metadata,
boolean forceConcurrencyCheck) |
Object |
trackEntity(Class<?> entityType,
JsonDocument documentFound)
Tracks the entity inside the unit of work
|
Object |
trackEntity(Class<?> entityType,
String key,
RavenJObject document,
RavenJObject metadata,
boolean noTracking)
Tracks the entity.
|
void |
trackIncludedDocument(JsonDocument include) |
void |
unregisterMissing(String id) |
protected void |
updateBatchResults(List<BatchResult> batchResults,
SaveChangesData saveChangesData)
Updates the batch results.
|
Map<String,List<DocumentsChanges>> |
whatChanged() |
protected final List<ILazyOperation> pendingLazyOperations
protected final Map<ILazyOperation,Action1<Object>> onEvaluateLazy
protected boolean generateDocumentKeysOnStore
protected static final ILog log
protected final Map<Object,DocumentMetadata> entitiesAndMetadata
protected final Map<String,JsonDocument> includedDocumentsByKey
protected final String dbName
protected final DocumentSessionListeners theListeners
protected String _databaseName
public EntityToJson entityToJson
protected InMemoryDocumentSessionOperations(String dbName, DocumentStoreBase documentStore, DocumentSessionListeners listeners, UUID id)
InMemoryDocumentSessionOperations
class.dbName
- documentStore
- listeners
- id
- public DocumentSessionListeners getListeners()
public int getNumberOfEntitiesInUnitOfWork()
public int getNumberOfRequests()
public IDocumentStore getDocumentStore()
public UUID getId()
public void setDatabaseName(String databaseName)
public String getDatabaseName()
public Long getNonAuthoritativeInformationTimeout()
public void setNonAuthoritativeInformationTimeout(Long nonAuthoritativeInformationTimeout)
nonAuthoritativeInformationTimeout
- public String getStoreIdentifier()
public DocumentConvention getConventions()
DocumentConvention
should be done
via the IDocumentStore
instance, not on a single session.public int getMaxNumberOfRequestsPerSession()
public void setMaxNumberOfRequestsPerSession(int maxNumberOfRequestsPerSession)
maxNumberOfRequestsPerSession
- public boolean isUseOptimisticConcurrency()
ConcurrencyException
public void setUseOptimisticConcurrency(boolean useOptimisticConcurrency)
ConcurrencyException
public <T> Etag getEtagFor(T instance)
instance
- public <T> RavenJObject getMetadataFor(T instance)
instance
- protected <T> DocumentMetadata getDocumentMetadataValue(T instance, Reference<String> idHolder, JsonDocument jsonDocument)
protected abstract JsonDocument getJsonDocument(String documentKey)
documentKey
- public boolean isLoaded(String id)
id
- public boolean isDeleted(String id)
id
- public String getDocumentId(Object instance)
instance
- public boolean hasChanges()
public boolean hasChanged(Object entity)
entity
- public void incrementRequestCount()
public Object trackEntity(Class<?> entityType, JsonDocument documentFound)
entityType
- documentFound
- public Object trackEntity(Class<?> entityType, String key, RavenJObject document, RavenJObject metadata, boolean noTracking)
entityType
- The entityTypekey
- The keydocument
- The documentmetadata
- The metadatanoTracking
- Entity tracking is enabled if true, disabled otherwise.public Object convertToEntity(Class<?> entityType, String id, RavenJObject documentFound, RavenJObject metadata, boolean isStreaming)
entityType
- id
- The id.documentFound
- The document foundmetadata
- The metadataisStreaming
- Is the conversion is part of the streaming? If yes, no sense in registering missing propertiespublic boolean isAllowNonAuthoritativeInformation()
public void setAllowNonAuthoritativeInformation(boolean allowNonAuthoritativeInformation)
public <T> void delete(T entity)
public <T> void delete(Class<T> clazz, Number id)
public <T> void delete(Class<T> clazz, UUID id)
public void delete(String id)
public static void ensureNotReadVetoed(RavenJObject metadata)
public void store(Object entity)
entity
- public void store(Object entity, Etag etag)
entity
- etag
- public void store(Object entity, String id)
entity
- id
- public void store(Object entity, Etag etag, String id)
entity
- etag
- id
- protected void rememberEntityForDocumentKeyGeneration(Object entity)
protected void storeEntityInUnitOfWork(String id, Object entity, Etag etag, RavenJObject metadata, boolean forceConcurrencyCheck)
protected ICommandData createPutEntityCommand(Object entity, DocumentMetadata documentMetadata)
entity
- documentMetadata
- protected void updateBatchResults(List<BatchResult> batchResults, SaveChangesData saveChangesData)
batchResults
- saveChangesData
- protected SaveChangesData prepareForSaveChanges()
public Map<String,List<DocumentsChanges>> whatChanged()
public void markReadOnly(Object entity)
entity
- public void ignoreChangesFor(Object entity)
protected boolean entityChanged(Object entity, DocumentMetadata documentMetadata)
protected boolean entityChanged(Object entity, DocumentMetadata documentMetadata, Map<String,List<DocumentsChanges>> changes)
entity
- documentMetadata
- The map of changespublic <T> void evict(T entity)
public void clear()
public EntityToJson getEntityToJson()
public GenerateEntityIdOnTheClient getGenerateEntityIdOnTheClient()
public void defer(ICommandData... commands)
public void explicitlyVersion(Object entity)
public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in interface CleanCloseable
protected void logBatch(SaveChangesData data)
public void registerMissing(String id)
public void unregisterMissing(String id)
public void registerMissingIncludes(Collection<RavenJObject> results, Collection<String> includes)
public Object projectionToInstance(RavenJObject y, Class<?> type)
protected void handleInternalMetadata(RavenJObject result)
public void trackIncludedDocument(JsonDocument include)
public boolean checkIfIdAlreadyIncluded(String[] ids, Tuple<String,Class<?>>[] includes)
public <T> void refreshInternal(T entity, JsonDocument jsonDocument, DocumentMetadata value)
Copyright © 2016. All Rights Reserved.