|
When persisting a class, a persistence solution needs to know how to persist the types of each field
in the class. Clearly a persistence solution can only support a finite number of Java types. It
cannot know how to persist every possible type creatable. The JDO/JPA specifications define lists of
types that are required to be supported by all implementations of those specifications.
This support can be conveniently split into two parts
-
An object that can be
referred-to
(object reference, providing a relation) and that has an
"identity" -
First Class Object (FCO)
. JDO2 requires an implementation to support
PersistenceCapable
types, as well as object/interface fields that refer to
PersistenceCapable
objects. JPA1 requires support for fields that are entity types.
DataNucleus provides support for JDO2/JPA1 FCOs
-
An object that does not have an "identity" -
Second Class Object (SCO)
. This is something
like a String or Date field in a class. It can also be a Collection, that contains other objects.
DataNucleus provides full support for JDO2/JPA1 SCOs, as well as support for many more types.
Indeed, if the type that you want to persist (as "SCO") is not listed below you can always add
support for it via a DataNucleus plugin using the
RDBMS Java Types Plugin guide
DataNucleus currently supports objects that are
PersistenceCapable
as
FCO
. In
addition it supports persisting fields of Interface or java.lang.Object type as FCO (since these
are just references to PersistenceCapable objects).
The table below shows the currently supported
SCO
java types in DataNucleus (and the
specifications requiring its support). The table also shows the default-fetch-group (DFG) setting
for that Java type (so whether it is retrieved by default when retrieving an object with a field
of that type), whether the field is persisted by default (if it is "false" then you would have to
add
persistence-modifier="persistent"
to the field for it to be persisted by JDO), and
whether the java type is replaced by a wrapper (or proxy) type that intercepts all methods that
change the object internally (this is used for dirty detection, and is most common with
collections/maps. You will see no difference when using the field of this type. The final column
lists the DataNucleus jar where you will find support for this type
|
Java Type
|
Spec.
|
DFG?
|
Persistent?
|
Proxied?
|
PK?
|
Plugin
|
|
boolean
|

|
|
|
|
|
datanucleus-core
|
|
byte
|

|
|
|
|
|
datanucleus-core
|
|
char
|

|
|
|
|
|
datanucleus-core
|
|
double
|

|
|
|
|
|
datanucleus-core
|
|
float
|

|
|
|
|
|
datanucleus-core
|
|
int
|

|
|
|
|
|
datanucleus-core
|
|
long
|

|
|
|
|
|
datanucleus-core
|
|
short
|

|
|
|
|
|
datanucleus-core
|
|
boolean[]
|
|
|
|
|
|
datanucleus-core
|
|
byte[]
|

|
|
|
|
|
datanucleus-core
|
|
char[]
|

|
|
|
|
|
datanucleus-core
|
|
double[]
|
|
|
|
|
|
datanucleus-core
|
|
float[]
|
|
|
|
|
|
datanucleus-core
|
|
int[]
|
|
|
|
|
|
datanucleus-core
|
|
long[]
|
|
|
|
|
|
datanucleus-core
|
|
short[]
|
|
|
|
|
|
datanucleus-core
|
|
java.lang.Boolean
|

|
|
|
|
|
datanucleus-core
|
|
java.lang.Byte
|

|
|
|
|
|
datanucleus-core
|
|
java.lang.Character
|

|
|
|
|
|
datanucleus-core
|
|
java.lang.Double
|

|
|
|
|
|
datanucleus-core
|
|
java.lang.Float
|

|
|
|
|
|
datanucleus-core
|
|
java.lang.Integer
|

|
|
|
|
|
datanucleus-core
|
|
java.lang.Long
|

|
|
|
|
|
datanucleus-core
|
|
java.lang.Short
|

|
|
|
|
|
datanucleus-core
|
|
java.lang.Boolean[]
|
|
|
|
|
|
datanucleus-core
|
|
java.lang.Byte[]
|

|
|
|
|
|
datanucleus-core
|
|
java.lang.Character[]
|

|
|
|
|
|
datanucleus-core
|
|
java.lang.Double[]
|
|
|
|
|
|
datanucleus-core
|
|
java.lang.Float[]
|
|
|
|
|
|
datanucleus-core
|
|
java.lang.Integer[]
|
|
|
|
|
|
datanucleus-core
|
|
java.lang.Long[]
|
|
|
|
|
|
datanucleus-core
|
|
java.lang.Short[]
|
|
|
|
|
|
datanucleus-core
|
|
java.lang.Number [4]
|
|
|
|
|
|
datanucleus-core
|
|
java.lang.Object
|
|
|
|
|
|
datanucleus-core
|
|
java.lang.String
|

|
|
|
|
|
datanucleus-core
|
|
java.lang.StringBuffer [3]
|
|
|
|
|
|
datanucleus-core
|
|
java.lang.String[]
|
|
|
|
|
|
datanucleus-core
|
|
java.math.BigDecimal
|

|
|
|
|
|
datanucleus-core
|
|
java.math.BigInteger
|

|
|
|
|
|
datanucleus-core
|
|
java.math.BigDecimal[]
|
|
|
|
|
|
datanucleus-core
|
|
java.math.BigInteger[]
|
|
|
|
|
|
datanucleus-core
|
|
java.sql.Date
|

|
|
|
|
|
datanucleus-core
|
|
java.sql.Time
|

|
|
|
|
|
datanucleus-core
|
|
java.sql.Timestamp
|

|
|
|
|
|
datanucleus-core
|
|
java.util.ArrayList
|

|
|
|
|
|
datanucleus-core
|
|
java.util.BitSet
|
|
|
|
|
|
datanucleus-core
|
|
java.util.Calendar
|
|
|
|
|
|
datanucleus-core
|
|
java.util.Collection
|

|
|
|
|
|
datanucleus-core
|
|
java.util.Currency
|
|
|
|
|
|
datanucleus-core
|
|
java.util.Date
|

|
|
|
|
|
datanucleus-core
|
|
java.util.Date[]
|
|
|
|
|
|
datanucleus-core
|
|
java.util.GregorianCalendar [7]
|
|
|
|
|
|
datanucleus-core
|
|
java.util.HashMap
|

|
|
|
|
|
datanucleus-core
|
|
java.util.HashSet
|

|
|
|
|
|
datanucleus-core
|
|
java.util.Hashtable
|

|
|
|
|
|
datanucleus-core
|
|
java.util.LinkedHashMap [5]
|

|
|
|
|
|
datanucleus-core
|
|
java.util.LinkedHashSet [6]
|

|
|
|
|
|
datanucleus-core
|
|
java.util.LinkedList
|

|
|
|
|
|
datanucleus-core
|
|
java.util.List
|

|
|
|
|
|
datanucleus-core
|
|
java.util.Locale
|
|
|
|
|
|
datanucleus-core
|
|
java.util.Locale[]
|
|
|
|
|
|
datanucleus-core
|
|
java.util.Map
|

|
|
|
|
|
datanucleus-core
|
|
java.util.Properties
|
|
|
|
|
|
datanucleus-core
|
|
java.util.PriorityQueue
|
|
|
|
|
|
datanucleus-core
|
|
java.util.Queue
|
|
|
|
|
|
datanucleus-core
|
|
java.util.Set
|

|
|
|
|
|
datanucleus-core
|
|
java.util.SortedMap [2]
|
|
|
|
|
|
datanucleus-core
|
|
java.util.SortedSet [1]
|
|
|
|
|
|
datanucleus-core
|
|
java.util.Stack
|
|
|
|
|
|
datanucleus-core
|
|
java.util.TimeZone
|
|
|
|
|
|
datanucleus-core
|
|
java.util.TreeMap [2]
|
|
|
|
|
|
datanucleus-core
|
|
java.util.TreeSet [1]
|
|
|
|
|
|
datanucleus-core
|
|
java.util.UUID
|
|
|
|
|
|
datanucleus-core
|
|
java.util.Vector
|

|
|
|
|
|
datanucleus-core
|
|
java.awt.Color
|
|
|
|
|
|
datanucleus-core
|
|
java.awt.Point
|
|
|
|
|
|
datanucleus-core
|
|
java.awt.image.BufferedImage
|
|
|
|
|
|
datanucleus-core
|
|
java.net.URI
|
|
|
|
|
|
datanucleus-core
|
|
java.net.URL
|
|
|
|
|
|
datanucleus-core
|
|
java.io.Serializable
|

|
|
|
|
|
datanucleus-core
|
|
javax.jdo.spi.PersistenceCapable
|
|
|
|
|
|
datanucleus-core
|
|
javax.jdo.spi.PersistenceCapable[]
|
|
|
|
|
|
datanucleus-core
|
|
java.lang.Enum
|

|
|
|
|
|
datanucleus-java5
|
|
java.lang.Enum[]
|

|
|
|
|
|
datanucleus-java5
|
-
[1]
-
java.util.SortedSet
,
java.util.TreeSet
allow the specification of comparators
via the "comparator-name" DataNucleus extension MetaData element (within <collection>).
The headSet, tailSet, subSet methods are only supported when using cached collections.
-
[2]
-
java.util.SortedMap
,
java.util.TreeMap
allow the specification of comparators
via the "comparator-name" DataNucleus extension MetaData element (within <map>).
The headMap, tailMap, subMap methods are only supported when using cached containers.
-
[3]
-
java.lang.StringBuffer
dirty check mechanism is limited to immutable mode,
it means, if you change a StringBuffer object field, you must reassign it to the owner object field to make sure
changes are propagated to the database.
-
[4]
-
java.lang.Number
will be stored in a column capable of storing a BigDecimal, and will store
to the precision of the object to be persisted. On reading back the object will be returned typically as
a BigDecimal since there is no mechanism for determing the type of the object that was stored.
-
[5]
-
java.util.LinkedHashMap
treated as a Map currently. No List-ordering
is supported.
-
[6]
-
java.util.LinkedHashSet
treated as a Set currently. No List-ordering
is supported.
-
[7]
-
java.util.Calendar
can be stored into two columns (millisecs, Timezone)
or into a single column (Timestamp). The single column option is not guaranteed to
preserve the TimeZone of the input Calendar.
Other DataNucleus plugins, for example RDBMS Spatial
add on support for other Java types. You can also make use of the Java types extension and easily
add support for your own types.
|
|