|
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 specification 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" is termed a
First Class Object (FCO)
. DataNucleus supports the
following Java types as FCO
-
PersistenceCapable
: any class marked for persistence can be persisted
with its own identity in the datastore
-
interface
where the field represents a
PersistenceCapable
object
-
java.lang.Object
where the field represents a
PersistenceCapable
object
An object that does not have an "identity" is termed a
Second Class Object (SCO)
.
This is something like a String or Date field in a class, or alternatively a Collection (that
contains other objects). The table below shows the currently supported
SCO
java types
in DataNucleus. The table shows
-
Extension?
: whether the type is JDO2 standard, or is a DataNucleus extension
-
default-fetch-group (DFG)
: whether the field is retrieved by default when
retrieving the object itself
-
persistence-modifier
: whether the field is persisted by default, or whether
the user has to mark the field as persistent in XML/annotations to persist it
-
proxied
: whether the field is represented by a "proxy" that intercepts
any operations to detect whether it has changed internally.
-
primary-key
: whether the field can be used as part of the primary-key
|
Java Type
|
Extension?
|
DFG?
|
Persistent?
|
Proxied?
|
PK?
|
|
boolean
|
|
|
|
|
|
|
byte
|
|
|
|
|
|
|
char
|
|
|
|
|
|
|
double
|
|
|
|
|
|
|
float
|
|
|
|
|
|
|
int
|
|
|
|
|
|
|
long
|
|
|
|
|
|
|
short
|
|
|
|
|
|
|
boolean[]
|
|
|
|
|
|
|
byte[]
|
|
|
|
|
|
|
char[]
|
|
|
|
|
|
|
double[]
|
|
|
|
|
|
|
float[]
|
|
|
|
|
|
|
int[]
|
|
|
|
|
|
|
long[]
|
|
|
|
|
|
|
short[]
|
|
|
|
|
|
|
java.lang.Boolean
|
|
|
|
|
|
|
java.lang.Byte
|
|
|
|
|
|
|
java.lang.Character
|
|
|
|
|
|
|
java.lang.Double
|
|
|
|
|
|
|
java.lang.Float
|
|
|
|
|
|
|
java.lang.Integer
|
|
|
|
|
|
|
java.lang.Long
|
|
|
|
|
|
|
java.lang.Short
|
|
|
|
|
|
|
java.lang.Boolean[]
|
|
|
|
|
|
|
java.lang.Byte[]
|
|
|
|
|
|
|
java.lang.Character[]
|
|
|
|
|
|
|
java.lang.Double[]
|
|
|
|
|
|
|
java.lang.Float[]
|
|
|
|
|
|
|
java.lang.Integer[]
|
|
|
|
|
|
|
java.lang.Long[]
|
|
|
|
|
|
|
java.lang.Short[]
|
|
|
|
|
|
|
java.lang.Number [4]
|
|
|
|
|
|
|
java.lang.Object
|
|
|
|
|
|
|
java.lang.String
|
|
|
|
|
|
|
java.lang.StringBuffer [3]
|
|
|
|
|
|
|
java.lang.String[]
|
|
|
|
|
|
|
java.math.BigDecimal
|
|
|
|
|
|
|
java.math.BigInteger
|
|
|
|
|
|
|
java.math.BigDecimal[]
|
|
|
|
|
|
|
java.math.BigInteger[]
|
|
|
|
|
|
|
java.sql.Date
|
|
|
|
|
|
|
java.sql.Time
|
|
|
|
|
|
|
java.sql.Timestamp
|
|
|
|
|
|
|
java.util.ArrayList
|
|
|
|
|
|
|
java.util.BitSet
|
|
|
|
|
|
|
java.util.Calendar
|
|
|
|
|
|
|
java.util.Collection
|
|
|
|
|
|
|
java.util.Currency
|
|
|
|
|
|
|
java.util.Date
|
|
|
|
|
|
|
java.util.Date[]
|
|
|
|
|
|
|
java.util.GregorianCalendar [7]
|
|
|
|
|
|
|
java.util.HashMap
|
|
|
|
|
|
|
java.util.HashSet
|
|
|
|
|
|
|
java.util.Hashtable
|
|
|
|
|
|
|
java.util.LinkedHashMap [5]
|
|
|
|
|
|
|
java.util.LinkedHashSet [6]
|
|
|
|
|
|
|
java.util.LinkedList
|
|
|
|
|
|
|
java.util.List
|
|
|
|
|
|
|
java.util.Locale
|
|
|
|
|
|
|
java.util.Locale[]
|
|
|
|
|
|
|
java.util.Map
|
|
|
|
|
|
|
java.util.Properties
|
|
|
|
|
|
|
java.util.PriorityQueue
|
|
|
|
|
|
|
java.util.Queue
|
|
|
|
|
|
|
java.util.Set
|
|
|
|
|
|
|
java.util.SortedMap [2]
|
|
|
|
|
|
|
java.util.SortedSet [1]
|
|
|
|
|
|
|
java.util.Stack
|
|
|
|
|
|
|
java.util.TimeZone
|
|
|
|
|
|
|
java.util.TreeMap [2]
|
|
|
|
|
|
|
java.util.TreeSet [1]
|
|
|
|
|
|
|
java.util.UUID
|
|
|
|
|
|
|
java.util.Vector
|
|
|
|
|
|
|
java.awt.Color
|
|
|
|
|
|
|
java.awt.Point
|
|
|
|
|
|
|
java.awt.image.BufferedImage
|
|
|
|
|
|
|
java.net.URI
|
|
|
|
|
|
|
java.net.URL
|
|
|
|
|
|
|
java.io.Serializable
|
|
|
|
|
|
|
javax.jdo.spi.PersistenceCapable
|
|
|
|
|
|
|
javax.jdo.spi.PersistenceCapable[]
|
|
|
|
|
|
|
java.lang.Enum
|
|
|
|
|
|
|
java.lang.Enum[]
|
|
|
|
|
|
-
[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.
Note that support is available for persisting other types depending on the datastore to which
you are persisting
If you have support for any additional types and would either like to contribute them, or
have them listed here, let us know
DataNucleus allows you the luxury of being able to provide SCO support for your own Java types
when using RDBMS datastores
|
|