JPOX
JPOX
 Project  |  Ver 1.1  |  Ver 1.2  |  JDO  |  JPA  |  Guides  |  Tools
1.2 | Persistence | JDO ORM | JPA ORM | Runtime | JDO Runtime | JPA Runtime | Extensions | Developer
JPOX Runtime
RDBMS Datastores
DB4O Datastore
Datastore Types

As we saw in the Types Guide JPOX supports the persistence of a large range of Java field types. With RDBMS datastores, we have the notion of tables/columns in the datastore and so each Java type is mapped across to a column or a set of columns in a table. It is important to understand this mapping when mapping to an existing schema for example. In RDBMS datastores a java type is stored using JDBC types. JPOX supports the use of the vast majority of the available JDBC types.

JDBC types used when persisting Java types

When persisting a Java type in general it is persisted into a single column. For example a String will be persisted into a VARCHAR column by default. Some types (e.g Color) have more information to store than we can conveniently persist into a single column and so use multiple columns. Other types (e.g Collection) store their information in other ways, such as foreign keys.

This table shows the Java types we saw earlier and whether they can be queried using JDOQL queries, and what JDBC types can be used to store them in your RDBMS datastore. Not all RDBMS datastores support all of these options. While JPOX always tries to provide a complete list sometimes this is impossible due to limitations in the underlying JDBC driver

Java TypeNumber

Columns
QueryableJDBC Type(s)
boolean1BIT, CHAR ('Y','N'), BOOLEAN, TINYINT, SMALLINT, NUMERIC
byte1TINYINT, SMALLINT, NUMERIC
char1CHAR, INTEGER, NUMERIC
double1DOUBLE, DECIMAL, FLOAT
float1FLOAT, REAL, DOUBLE, DECIMAL
int1INTEGER, BIGINT, NUMERIC
long1BIGINT, NUMERIC, DOUBLE, DECIMAL, INTEGER
short1SMALLINT, INTEGER, NUMERIC
boolean[]1 [6]LONGVARBINARY, BLOB
byte[]1 [6]LONGVARBINARY, BLOB
char[]1 [6]LONGVARBINARY, BLOB
double[]1 [6]LONGVARBINARY, BLOB
float[]1 [6]LONGVARBINARY, BLOB
int[]1 [6]LONGVARBINARY, BLOB
long[]1 [6]LONGVARBINARY, BLOB
short[]1 [6]LONGVARBINARY, BLOB
java.lang.Boolean1BIT, CHAR('Y','N'), BOOLEAN, TINYINT, SMALLINT
java.lang.Byte1TINYINT, SMALLINT, NUMERIC
java.lang.Character1CHAR, INTEGER, NUMERIC
java.lang.Double1DOUBLE, DECIMAL, FLOAT
java.lang.Float1FLOAT, REAL, DOUBLE, DECIMAL
java.lang.Integer1INTEGER, BIGINT, NUMERIC
java.lang.Long1BIGINT, NUMERIC, DOUBLE, DECIMAL, INTEGER
java.lang.Short1SMALLINT, INTEGER, NUMERIC
java.lang.Boolean[]1 [6]LONGVARBINARY, BLOB
java.lang.Byte[]1 [6]LONGVARBINARY, BLOB
java.lang.Character[]1 [6]LONGVARBINARY, BLOB
java.lang.Double[]1 [6]LONGVARBINARY, BLOB
java.lang.Float[]1 [6]LONGVARBINARY, BLOB
java.lang.Integer[]1 [6]LONGVARBINARY, BLOB
java.lang.Long[]1 [6]LONGVARBINARY, BLOB
java.lang.Short[]1 [6]LONGVARBINARY, BLOB
java.lang.Number1
java.lang.Object1LONGVARBINARY, BLOB
java.lang.String [9]1VARCHAR, CHAR, LONGVARCHAR, CLOB, BLOB, DATALINK [7], UNIQUEIDENTIFIER [8], XMLTYPE [10]
java.lang.StringBuffer [9]1VARCHAR, CHAR, LONGVARCHAR, CLOB, BLOB, DATALINK [7], UNIQUEIDENTIFIER [8], XMLTYPE [10]
java.lang.String[]1 [6]LONGVARBINARY, BLOB
java.math.BigDecimal1DECIMAL, NUMERIC
java.math.BigInteger1NUMERIC, DECIMAL
java.math.BigDecimal[]1 [6]LONGVARBINARY, BLOB
java.math.BigInteger[]1 [6]LONGVARBINARY, BLOB
java.sql.Date1DATE, TIMESTAMP
java.sql.Time1TIME, TIMESTAMP
java.sql.Timestamp1TIMESTAMP
java.util.ArrayList0
java.util.BitSet0LONGVARBINARY, BLOB
java.util.Calendar [3]1 or 2INTEGER, VARCHAR, CHAR
java.util.Collection0
java.util.Currency1VARCHAR, CHAR
java.util.Date1TIMESTAMP, DATE, CHAR, BIGINT
java.util.Date[]1 [6]LONGVARBINARY, BLOB
java.util.GregorianCalendar [2]1 or 2INTEGER, VARCHAR, CHAR
java.util.HashMap0
java.util.HashSet0
java.util.Hashtable0
java.util.LinkedHashMap0
java.util.LinkedHashSet0
java.util.LinkedList0
java.util.List0
java.util.Locale [9]1VARCHAR, CHAR, LONGVARCHAR, CLOB, BLOB, DATALINK [7], UNIQUEIDENTIFIER [8], XMLTYPE [10]
java.util.Locale[]1 [6]LONGVARBINARY, BLOB
java.util.Map0
java.util.Properties0
java.util.PriorityQueue0
java.util.Queue0
java.util.Set0
java.util.SortedMap0
java.util.SortedSet0
java.util.Stack0
java.util.TimeZone [9]1VARCHAR, CHAR, LONGVARCHAR, CLOB, BLOB, DATALINK [7], UNIQUEIDENTIFIER [8], XMLTYPE [10]
java.util.TreeMap0
java.util.TreeSet0
java.util.UUID [9]1VARCHAR, CHAR, LONGVARCHAR, CLOB, BLOB, DATALINK [7], UNIQUEIDENTIFIER [8], XMLTYPE [10]
java.util.Vector0
java.awt.Color [1]4INTEGER
java.awt.Point [2]2INTEGER
java.awt.image.BufferedImage [5]1LONGVARBINARY, BLOB
java.net.URI [9]1VARCHAR, CHAR, LONGVARCHAR, CLOB, BLOB, DATALINK [7], UNIQUEIDENTIFIER [8], XMLTYPE [10]
java.net.URL [9]1VARCHAR, CHAR, LONGVARCHAR, CLOB, BLOB, DATALINK [7], UNIQUEIDENTIFIER [8], XMLTYPE [10]
java.io.Serializable1LONGVARBINARY, BLOB
javax.jdo.spi.PersistenceCapable1[embedded]
javax.jdo.spi.PersistenceCapable[]1 [6]
java.lang.Enum [4]1LONGVARBINARY, BLOB, VARCHAR, INTEGER
  • [1] - java.awt.Color - stored in 4 columns (red, green, blue, alpha). ColorSpace is not persisted.
  • [2] - java.awt.Point - stored in 2 columns (x and y).
  • [3] - java.util.Calendar - stored in 2 columns (milliseconds and timezone).
  • [4] - 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.
  • [5] - java.awt.image.BufferedImage is stored using JPG image format
  • [6] - Array types are queryable if not serialised, but stored to many rows
  • [7] - DATALINK JDBC type supported on DB2 only. Uses the SQL function DLURLCOMPLETEONLY to fetch from the datastore. You can override this using the select-function extension. See the JDO MetaData reference.
  • [8] - UNIQUEIDENTIFIER JDBC type supported on MSSQL only.
  • [9] - Oracle treats an empty string as the same as NULL. To workaround this limitation JPOX replaces the empty string with the character \u0001.
  • [10] - XMLTYPE JDBC type supported on Oracle only, and is included in the "jpox-xmltypeoracle" plugin.


Supported JDBC types

JPOX provides support for the majority of the JDBC types. The support is shown below.

JDBC TypeSupportedRestrictions
ARRAY
BIGINT
BINARYOnly for spatial types on MySQL
BIT
BLOB
BOOLEAN
CHAR
CLOB
DATALINKOnly on DB2
DATE
DECIMAL
DISTINCT
DOUBLE
FLOAT
INTEGER
JAVA_OBJECT
LONGVARBINARY
LONGVARCHAR
NULL
NUMERIC
OTHEROnly for spatial types on PostgreSQL with PostGIS extension
REAL
REF
SMALLINT
STRUCTOnly for spatial types on Oracle
TIME
TIMESTAMP
TINYINT
VARBINARY
VARCHAR