Conventions
Conventions give you the ability to customize the Client API behavior. They are accessible from DocumentStore
object:
try (IDocumentStore store = new DocumentStore()) {
DocumentConventions conventions = store.getConventions();
// customizations go here
store.initialize();
}
You will find many settings to overwrite, allowing you to adjust the client according to your needs. The conventions apply to many different client behaviors. Some of them are grouped and described in the separate articles of this section.
Information
All customizations need to be set before DocumentStore.initialize()
is called.
MaxHttpCacheSize
If you need to modify the maximum http cache size, you can use the following setting:
conventions.setMaxHttpCacheSize(256 * 1024 * 1024);
Default size
The default value of this setting is configured to 128 MB.
The cache is created per database you use.
Disable caching
To disable the caching globally you can set the maxHttpCacheSize
value to zero:
conventions.setMaxHttpCacheSize(0);
In this scenario, all the requests will be sent to the server to fetch the data.
MaxNumberOfRequestsPerSession
Gets or sets maximum number of GET requests per session. Default: 30
.
conventions.setMaxNumberOfRequestsPerSession(10);
UseOptimisticConcurrency
Controls whether optimistic concurrency is set to true by default for all future sessions. Default: false
.
conventions.setUseOptimisticConcurrency(true);
DisableTopologyUpdates
Forces you to disable updates of database topology. Default: false
.
conventions.setDisableTopologyUpdates(false);
SaveEnumsAsIntegers
It determines if Java Enum
types should be saved as integers or strings. Default: false
.
conventions.setSaveEnumsAsIntegers(true);
UseCompression
It determines if the client will send headers to the server indicating that it allows compression to be used. Default: true
.
conventions.setUseCompression(true);
Changing fields/properties naming convention
By default whatever casing convention you use in your entities' fields will be reflected server-side.
If following language-specific field casing conventions RavenDB clients use different field/properties naming conventions:
Language | Default convention | Example |
---|---|---|
C# | PascalCase | OrderLines |
Java | camelCase | orderLines |
JavaScript | camelCase | orderLines |
This can be configured to allow inter-language operability e.g. store data PascalCase, but keep fields in the application code camelCase.
Using PascalCase in Java client
You have to set property naming strategy:
conventions.getEntityMapper()
.setPropertyNamingStrategy(
new JsonExtensions.DotNetNamingStrategy());