|
Sometimes a datastore has particular requirements, and maybe is out of direct control of an application
being managed by a different group. In this situation you may have to configure the datastore layer
to meet these requirements.
If your datastore is read-only (you can't add/update/delete any data in it), obviously you
could just configure your application to not perform these operations. An alternative is
to set the PersistenceManagerFactory as "read-only". You do this by setting the
persistence property
javax.jdo.option.ReadOnly
to
true
.
From now on, whenever you perform a persistence operation that implies a change in datastore
data, the JDO operation will throw a
JDOReadOnlyException
.
This is included from JDO 2.2 onwards
(but has been in DataNucleus and JPOX before it
for a long time).
DataNucleus provides an additional control over the behaviour when an attempt is made to
change a read-only datastore. The default behaviour is to throw an exception. You can change this
using the persistence property
datanucleus.readOnlyDatastoreAction
with values of "EXCEPTION"
(default), and "IGNORE". "IGNORE" has the effect of simply ignoring all attempted updates to
readonly objects.
Some datastores have a "schema" defining the structure of data stored within that datastore.
In this case we don't want to allow updates to the structure at all. You can set this when creating
your PersistenceManagerFactory by setting the persistence property
datanucleus.fixedDatastore
to
true
.
|
|