Entity Management Settings
entities> configuration element specifies front end settings that are relevant on the client side and in embedded mode.
The default configuration file contains the following
<entities> <enhancement agent="true" reflection="warning" /> <cache ref="weak" level2="0mb" /> <fetch hollow="true" /> <persist serialization="false" /> <cascade-persist always="auto" on-persist="false" on-commit="true" /> <dirty-tracking arrays="false" /> </entities>
Each of the following sections describes one subelement:
The <enhancement> element
<enhancement agent="true" reflection="warning" />
<enhancement> element specifies enhancement related settings:
agentattribute (whose value is
"false") specifies whether the Enhancer Agent should be loaded to enhance persistable types on the fly, even if it is not specified explicitly at the command line. This is currently supported only for JDK 6.0 (not JRE) or above.
reflectionattribute specifies how non enhanced classes are handled. ObjectDB can manage non enhanced classes by using reflection at the cost of performance. The possible values of the
reflectionattribute represent different policies:
"error"- all persistable classes must be enhanced - otherwise an exception is thrown.
"warning"- a warning is logged for every non enhanced class.
ignore"- reflection is used for non enhanced classes - with no error or warning.
"force"- reflection is used even for enhanced classes (for troubleshooting).
The <cache> element
<cache ref="weak" level2="0mb" />
<cache> element specifies settings of the two cache mechanisms for entities:
refattribute specifies the reference type for holding non dirty entities in the persistence context of the
(which serves as a first level cache). The valid values are
EntityManagerjavax.persistence.EntityManagerJPA interfaceInterface used to interact with the persistence context.See JavaDoc Reference Page...
. Modified entities are always held by strong references in the persistence context (until
flush), regardless of this setting.
level2attribute specifies the size of the shared level 2 cache that is managed by the
EntityManagerFactoryjavax.persistence.EntityManagerFactoryJPA interfaceInterface used to interact with the entity manager factory for the persistence unit.See JavaDoc Reference Page... and shared by all its
EntityManagerinstances. The level 2 cache is disabled by specifying
The <fetch> element
<fetch hollow="true" />
attribute of the
<fetch> element (whose value is
"false") specifies if lazy loading of entity objects content is enabled. Instantiating entity objects as hollow, and loading their persistent content lazily, when they are accessed, could improve performance. However, for some applications disabling this ability could be more efficient.
The <persist> element
<persist serialization="false" />
serialization attribute of the
<persist> element (whose value is
"false") specifies if serialization should be used as a fallback persisting method for instances of serializable types that are non persistable otherwise (e.g. a user defined class, which is not an entity class, mapped super class or embeddable class).
The <cascade-persist> element
<cascade-persist always="auto" on-persist="false" on-commit="true" />
<cascade-persist> element specifies global settings for cascading persist operations:
- The always attribute (whose value is
"auto") specifies if persist operations should always be cascaded for every entity, regardless local cascade settings.
"auto"value functions as
"true"when using JDO and as
"false"when using JPA.
on-persistattribute specifies whether cascading (as a result of either global or local setting) should be applied during persist.
on-commitattribute specifies whether cascading (as a result of either global or local setting) should be applied during commit and flush.
Note: Both JPA and JDO require cascading the persist operation twice, first during persist and later on commit or flush. Usually, commit time only cascade (which is more efficient than double cascade) is sufficient.
The <dirty-tracking> element
<dirty-tracking arrays="false" />
arrays attribute of the
<dirty-tracking> element specifies if modifications to array cells should be tracked automatically in enhanced classes. See the Updating Entities section in chapter 3 for more details.