> For the complete documentation index, see [llms.txt](https://manual.docs.microstream.one/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://manual.docs.microstream.one/4.0/data-store/customizing/optional-storage-manager-reference-in-entities.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
