By default with JDO implementations when you open a
and obtain a
DataNucleus knows nothing about which classes are to be persisted to
that datastore. JDO implementations only load the Meta-Data for any class when the class is first
enlisted in a
operation. For example you call
an object. The first time a particular class is encountered DataNucleus will dynamically load the
Meta-Data for that class. This typically works well since in an application in a particular
may well not encounter all classes that are
persistable to that datastore. The reason for this dynamic loading is that JDO implementations
can't be expected to scan through the whole Java CLASSPATH for classes that could be persisted
there. That would be inefficient.
There are situations however where it is desirable for DataNucleus to have knowledge about what is to
be persisted, so that it can load the Meta-Data at initialisation of the persistence factory and
hence when the classes are encountered for the first time nothing needs doing. There are two
ways of providing this
Define your classes/MetaData in a Persistence Unit
and when the
is initialised it loads the persistence
unit, and hence the MetaData for the defined classes and mapping files.
This is described on the linked page
Use a DataNucleus extension known as
This is set with the persistence property
This can be set to
These are described below. Please note that other plugins, such as
RDBMS provide alternative options.
With this property set to "None" DataNucleus will have no knowledge about classes that are to be
persisted into that datastore and so will add the classes when the user utilises them in calls
to the various
, DataNucleus stores the information for starting up DataNucleus in an XML file.
This is, by default, located in datanucleusAutoStart.xml in the current working directory. The file name
can be configured using the persistence factory property
The file is read at startup and DataNucleus loads the classes using this information.
If the user changes their persistence definition a problem can occur when starting up DataNucleus.
DataNucleus loads up its existing data from the XML configuration file and finds that a
table/class required by the this file data no longer exists. There are 3 options for what
DataNucleus will do in this situation. The property
defines the behaviour of DataNucleus for this situation.
will mean that DataNucleus will throw an exception and the user will be
expected to manually fix their database mismatch (perhaps by removing the existing tables).
(the default) will simply remove the entry from the XML file and continue
will simply continue without doing anything.
, the user provides to the persistence factory the list of classes to
use as the initial list of classes to be persisted. They specify this via the persistence
, specifying the list of classes as
comma-separated. This gives DataNucleus a head start meaning that it will not need to
"discover" these classes later.
, the user provides to the persistence factory the list of metadata
files to use as the initial list of classes to be persisted. They specify this via the
, specifying the list of
metadata files as comma-separated. This gives DataNucleus a head start meaning that it
will not need to "discover" these classes later.