# Optional Storage Manager Reference in Entities

{% hint style="warning" %}
**This is the manual for older MicroStream versions (Version < 5.0).**

**The new documentation (Version >= 5.0) is located at:**

[https://docs.microstream.one/](https://docs.microstream.one/manual)
{% endhint %}

When a reference to the loading storage is needed in entities, e.g. usage of different tenants or to store its internal state in a tailored fashion, this can be done by this little trick.

If an entity type contains one or more transient fields with field type compatible to `Persister`, the updating processing during loading will set the `Persister` instance (e.g. an `EmbeddedStorageManager` instance) used to load the entity instance to those fields.

The fields must be transient to exclude them from the persistent form of the entity.\
Checking for transient fields is only the default implementation. The checking logic can be customized via `PersistenceFoundation#setFieldEvaluatorPersistable`.

A more precise check for `Persister` fields can be customized via `PersistenceFoundation#setFieldEvaluatorPersister`.\
Note, however, that the check for compatibility with the `Persister` type is done in any case to avoid inconsistencies/crashes.

If no applicable field is found, nothing happens and no additional meta data is kept in memory. This feature is completely optional.

```java
class MyEntity
{
	String name ;
	int    value;
	
	transient EmbeddedStorageManager storage;
}
```

Upon loading an instance of class `MyEntity`, a reference to the `EmbeddedStorageManager` used to load it is set to its field `storage`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://manual.docs.microstream.one/3.0/data-store/customizing/optional-storage-manager-reference-in-entities.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
