# Best Practice

{% 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 %}

## Storing Hidden Encapsulated Objects

In some cases, it can be necessary to store modified encapsulated objects that cannot be a accessed from your code.&#x20;

```java
public class ForeignObject
{
    ...
    private HiddenObject hidden;
    ...
}
```

In the upper code snippet the "hidden" object cannot be accessed by `store(myForeignObject.hidden)` if no getter is available. To allow such hidden objects to be stored after they have been modified you have to options:

1. Set the global storing strategy of the MicroStream instance to [eager storing](/2.1/data-store/storing-data/lazy-eager-full.md)\
   or
2. Implement and set a custom [`PersistenceEagerStoringFieldEvaluator`](/2.1/data-store/customizing/eager-storing-fields.md) for this field.

```java
EmbeddedStorageManager storage = EmbeddedStorage.Foundation()
	.onConnectionFoundation(
		f -> f.setReferenceFieldEagerEvaluator(
			new CustomEagerStoringFieldEvaluator()
		)
	)
	.start();
```

## Use Immutable data models

To increase performance use immutable sub-graphs as often as possible. Storing those with the provided [convenience storing methods](/2.1/data-store/storing-data/convenience-methods-and-explicit-storing-transactions.md) or using a thread local [storer ](/2.1/data-store/storing-data/lazy-eager-full.md#usage)to insert those sub-graphs concurrently can give a great performance boost.


---

# 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/2.1/data-store/storing-data/best-practice.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.
