JPOX
JPOX
 Project  |  Ver 1.1  |  Ver 1.2  |  JDO  |  JPA  |  Guides  |  Tools
1.1 | Preparation | O/R Mapping | Runtime | Extensions | Developer
Persistence
Object Identity
Supported Java Types

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. JDO uses terminology First-Class object (FCO) and Second-Class object (SCO) to categorize how these types are treated by the JDO implementation. Lets just explain what these mean.

  • FCO's are objects that have an identity in the datastore. They can be referred to. Examples of FCO's are an instance of a user-supplied class that is persistence capable.
  • SCO's are objects that do not have an identity in the datastore. They can't be referred to directly. They are aggregated to an FCO object and can be stored as part of the FCO object. SCO object can also contain FCO elements, like an FCO object has a SCO field of type Collection which contains FCO objects elements. Examples of SCO's are a field of type Date, that is typically stored as part of the FCO object.

If the type that you want to persist (as "SCO") is not listed below you can always add support for it via a JPOX plugin using the User-Types Plugin guide.



Supported First-Class (FCO) Types

JPOX 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).



Supported Second-Class (SCO) Types

The table below shows the currently supported SCO in JPOX (along with their JDBC type and default-fetch-group setting, whether they are queryable). It also shows the specifications which require support for the particular Java type. Please note that if your particular Java type is not listed below, it is possible for you to add support for it using a JPOX extension. It also shows whether a java type will be assigned a "proxy" object that allows detection of changes to the object. This is needed for things like Collections where you may add/remove elements and JPOX needs to know of updates. This use of a proxy will not affect your use of those types in any way. Please note that this list gives all JDBC types available with the various RDBMS adapters. The jdbc type in bold is the default type that will be used when "jdbc-type" is not specified in the MetaData (assuming that the RDBMS supports that JDBC type, and if not then JPOX will choose one itself). Some RDBMS adapters will only support some of these. The list will be improved in the future to add many more possibilities of persisting Java types using other JDBC types.

Java TypeSpec.DFG?Persistent?Proxied?QueryableJDBC Type(s)
booleanBIT, CHAR ('Y','N'), BOOLEAN, TINYINT, SMALLINT, NUMERIC
byteTINYINT, SMALLINT, NUMERIC
charCHAR, INTEGER, NUMERIC
doubleDOUBLE, DECIMAL, FLOAT
floatFLOAT, REAL, DOUBLE, DECIMAL
intINTEGER, BIGINT, NUMERIC
longBIGINT, NUMERIC, DOUBLE, DECIMAL, INTEGER
shortSMALLINT, INTEGER, NUMERIC
boolean[] [8]LONGVARBINARY, BLOB
byte[] [8]LONGVARBINARY, BLOB
char[] [8]LONGVARBINARY, BLOB
double[] [8]LONGVARBINARY, BLOB
float[] [8]LONGVARBINARY, BLOB
int[] [8]LONGVARBINARY, BLOB
long[] [8]LONGVARBINARY, BLOB
short[] [8]LONGVARBINARY, BLOB
java.lang.BooleanBIT, CHAR('Y','N'), BOOLEAN, TINYINT, SMALLINT
java.lang.ByteTINYINT, SMALLINT, NUMERIC
java.lang.CharacterCHAR, INTEGER, NUMERIC
java.lang.DoubleDOUBLE, DECIMAL, FLOAT
java.lang.FloatFLOAT, REAL, DOUBLE, DECIMAL
java.lang.IntegerINTEGER, BIGINT, NUMERIC
java.lang.LongBIGINT, NUMERIC, DOUBLE, DECIMAL, INTEGER
java.lang.ShortSMALLINT, INTEGER, NUMERIC
java.lang.Boolean[] [8]LONGVARBINARY, BLOB
java.lang.Byte[] [8]LONGVARBINARY, BLOB
java.lang.Character[] [8]LONGVARBINARY, BLOB
java.lang.Double[] [8]LONGVARBINARY, BLOB
java.lang.Float[] [8]LONGVARBINARY, BLOB
java.lang.Integer[] [8]LONGVARBINARY, BLOB
java.lang.Long[] [8]LONGVARBINARY, BLOB
java.lang.Short[] [8]LONGVARBINARY, BLOB
java.lang.Number
java.lang.ObjectLONGVARBINARY, BLOB
java.lang.StringVARCHAR, CHAR, LONGVARCHAR, CLOB, BLOB, DATALINK, UNIQUEIDENTIFIER
java.lang.String[] [8]LONGVARBINARY, BLOB
java.math.BigDecimalDECIMAL, NUMERIC
java.math.BigIntegerNUMERIC, DECIMAL
java.math.BigDecimal[] [8]LONGVARBINARY, BLOB
java.math.BigInteger[] [8]LONGVARBINARY, BLOB
java.sql.DateDATE, TIMESTAMP
java.sql.TimeTIME, TIMESTAMP
java.sql.TimestampTIMESTAMP
java.util.ArrayList
java.util.BitSetLONGVARBINARY, BLOB
java.util.Calendar [5]INTEGER, VARCHAR, CHAR
java.util.Collection
java.util.CurrencyVARCHAR, CHAR
java.util.DateTIMESTAMP, DATE, CHAR, BIGINT
java.util.Date[] [8]LONGVARBINARY, BLOB
java.util.GregorianCalendar [4]INTEGER, VARCHAR, CHAR
java.util.HashMap
java.util.HashSet
java.util.Hashtable
java.util.LinkedHashMap [9]
java.util.LinkedHashSet [10]
java.util.LinkedList
java.util.List
java.util.LocaleVARCHAR, CHAR, LONGVARCHAR, CLOB, BLOB, DATALINK, UNIQUEIDENTIFIER
java.util.Locale[] [8]LONGVARBINARY, BLOB
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.TimeZoneVARCHAR, CHAR, LONGVARCHAR, CLOB, BLOB, DATALINK, UNIQUEIDENTIFIER
java.util.TreeMap [2]
java.util.TreeSet [1]
java.util.UUIDVARCHAR, CHAR, LONGVARCHAR, CLOB, BLOB, DATALINK, UNIQUEIDENTIFIER
java.util.Vector
java.awt.Color [3]INTEGER
java.awt.Point [4]INTEGER
java.awt.image.BufferedImage [7]LONGVARBINARY, BLOB
java.net.URIVARCHAR, CHAR, LONGVARCHAR, CLOB, BLOB, DATALINK, UNIQUEIDENTIFIER
java.net.URLVARCHAR, CHAR, LONGVARCHAR, CLOB, BLOB, DATALINK, UNIQUEIDENTIFIER
java.io.SerializableLONGVARBINARY, BLOB
javax.jdo.spi.PersistenceCapable[embedded]
javax.jdo.spi.PersistenceCapable[] [8]
java.lang.Enum [6]LONGVARBINARY, BLOB, VARCHAR, INTEGER
  • [1] - java.util.SortedSet, java.util.TreeSet allow the specification of comparators via the "comparator-name" JPOX 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" JPOX extension MetaData element (within <map>). The headMap, tailMap, subMap methods are only supported when using cached containers.
  • [3] - java.awt.Color - stored in 4 columns (red, green, blue, alpha). ColorSpace is not persisted.
  • [4] - java.awt.Point - stored in 2 columns (x and y).
  • [5] - java.util.Calendar - stored in 2 columns (milliseconds and timezone).
  • [6] - java.lang.Enum - by default, serialized into one column. Storing in VARCHAR or INTEGER data types is available via the "Java5" plugin. Queryable if stored in VARCHAR or INTEGER columns.
  • [7] - java.awt.image.BufferedImage is stored using JPG image format
  • [8] - Array types are queryable if not serialised, but stored to many rows
  • [9] - java.util.LinkedHashMap is stored without ordering, hence as just a Map currently
  • [10] - java.util.LinkedHashSet is stored without ordering, hence as just a Set currently


Additional Information Second-Class (SCO) Types

Java TypeJDBC TypeDatabaseAdditional Information
java.lang.StringDATALINKDB2By default uses the SQL function: DLURLCOMPLETEONLY to fetch the column from database. This setting can be overwritten by the select-function extension. See the MetaData reference.
java.lang.StringVARCHAROracleOracle treats an empty string equals null. To workaround, JPOX replaces the empty string with the character \u0001.
java.lang.StringUNIQUEIDENTIFIERMSSQL



Supported Spatial Types

The table below shows the currently supported Spatial SCO in JPOX.

Java TypeSpec.DFG?Persistent?Proxied?QueryableJDBC Type(s)Plug-in
oracle.spatial.geometry.JGeometry [1]SDO_GEOMETRYSpatialOracle
  • [1] - oracle.spatial.geometry.JGeometry dirty check mechanism is limited to immutable mode, it means, if you change a JGeometry object field, you must reassign it to the owner object field to make sure changes are propaged to the database.


Supported JDBC Types

The types listed above are the types of the fields in your class. Here we also concern ourselves with the JDBC types that JPOX provides support for. This is important because these map onto the SQL types supported by your RDBMS.

JDBC TypeSupportedRestrictions
ARRAY
BIGINT
BINARY
BIT
BLOB
BOOLEAN
CHAR
CLOB
DATALINKOnly on DB2
DATE
DECIMAL
DISTINCT
DOUBLE
FLOAT
INTEGER
JAVA_OBJECT
LONGVARBINARY
LONGVARCHAR
NULL
NUMERIC
OTHER
REAL
REF
SMALLINT
STRUCT
TIME
TIMESTAMP
TINYINT
VARBINARY
VARCHAR