Oracle TopLink Developer's Guide
10g Release 3 (10.1.3) B13593-01 |
|
![]() Previous |
![]() Next |
Figure 6-1 summarizes the important SchemaManager
classes and the primary means of using them.
Although you can use the SchemaManager
API directly, Oracle recommends that you create a TableCreator
class and use its API (which, in turn, uses the SchemaManager
).
You can automatically generate a TableCreator
using:
TopLink Workbench during development (see "Using TopLink Workbench During Development")
DefaultTableGenerator
at run time (see "Using the Default Table Generator at Run Time")
The TableCreator
class owns one or more TableDefinition
classes (one for each database table) and the TableDefinition
class owns one or more FieldDefinition
classes (one for each field).
The TableDefinition
class lets you specify a database table schema in a generic format. At run time, TopLink uses the session associated with your TopLink project to determine the specific database type, and uses the generic schema to create the appropriate tables and fields for that database.
After creating a TableCreator
class, you can use its API to create and drop tables (see "Creating Tables With a Table Creator"). You can also configure TopLink to do this automatically (see "Automatic Database Table Creation").
Because the schema manager uses Java types rather than database types, it is database-independent. However, because it does not account for database-specific optimizations, it is best-suited for development purposes rather than production. For more information on how the schema manager maps Java types to database types, see "Schema Manager Java and Database Type Conversion".
Although the schema manager can handle the sequencing configuration that you specify in your TopLink project, if you are using sequencing with non-Oracle databases, there are some sequencing restrictions you should be aware of (see "Sequencing").
Table 6-1 lists the Java type to database type conversions that the schema manager supports depending on the database platform your TopLink project uses. This list is specific to the schema manager and does not apply to mappings. TopLink automatically performs conversions between any database types within mappings.
Table 6-1 Java and Database Field Type Conversion
Java Type | Database Type | ||||
---|---|---|---|---|---|
Oracle | DB2 | Sybase | MySQL | MS Access | |
|
NUMBER |
SMALLINT |
BIT default 0 |
TINYINT(1) |
SHORT |
|
NUMBER |
SMALLINT |
SMALLINT |
TINYINT |
SHORT |
|
LONG RAW |
BLOB |
IMAGE |
BLOB |
LONGBINARY |
|
CHAR |
CHAR |
CHAR |
CHAR |
TEXT |
|
LONG |
CLOB |
TEXT |
TEXT |
LONGTEXT |
|
NUMBER |
FLOAT |
FLOAT(32) |
DOUBLE |
DOUBLE |
|
NUMBER |
FLOAT |
FLOAT(16) |
FLOAT |
DOUBLE |
|
NUMBER |
INTEGER |
INTEGER |
INTEGER |
LONG |
|
NUMBER |
INTEGER |
NUMERIC |
BIGINT |
DOUBLE |
|
NUMBER |
SMALLINT |
SMALLINT |
SMALLINT |
SHORT |
|
VARCHAR2 |
VARCHAR |
VARCHAR |
VARCHAR |
TEXT |
|
NUMBER |
DECIMAL |
NUMERIC |
DECIMAL |
DOUBLE |
|
NUMBER |
DECIMAL |
NUMERIC |
BIGINT |
DOUBLE |
|
DATE |
DATE |
DATETIME |
DATE |
DATETIME |
|
DATE |
TIME |
DATETIME |
TIME |
DATETIME |
|
DATE |
TIMESTAMP |
DATETIME |
DATETIME |
DATETIME |
For more information about database platforms that TopLink supports, see "Database Platforms".
If you generate a TableCreator
class using TopLink Workbench (see "Using TopLink Workbench During Development") or DefaultTableGenerator
(see "Using the Default Table Generator at Run Time"), then sequencing configuration is included in your TableCreator
according to your TopLink project configuration. In this case, when you use TableCreator
method createTables
, it does the following:
Creates the sequence table as defined in the session DatabaseLogin
Creates or inserts sequences for each sequence name for all registered descriptors in the session
Creates the Oracle sequence object if you use Oracle native sequencing
You can use advanced API to handle special cases like Sybase or Microsoft SQL Server native sequencing (see "Using Java").
For more information about sequencing, see "Understanding Sequencing in Relational Projects".