Package org.apache.openjpa.jdbc.schema
Class TableSchemaFactory
- java.lang.Object
-
- org.apache.openjpa.jdbc.schema.TableSchemaFactory
-
- All Implemented Interfaces:
SchemaFactory
,Configurable
public class TableSchemaFactory extends java.lang.Object implements SchemaFactory, Configurable
Factory that uses an XML schema definition stored in a database table to record the system schema.- Author:
- Abe White
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ACTION_ADD
static java.lang.String
ACTION_DROP
-
Constructor Summary
Constructors Constructor Description TableSchemaFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
dropTable()
Drops the sequence table in the DB.void
endConfiguration()
Invoked upon completion of bean property configuration for this object.JDBCConfiguration
getConfiguration()
java.lang.String
getPrimaryKeyColumn()
The name of the primary key column on the schema definition table.java.lang.String
getSchemaColumn()
The name of the schema column on the schema definition table.java.lang.String
getTable()
The name of the schema definition table.static void
main(java.lang.String[] args)
Usage: java org.apache.openjpa.jdbc.schema.TableSchemaFactory [option]* -action/-a <add | drop> Where the following options are recognized.SchemaGroup
readSchema()
Return the schema group for the current object model and database.java.lang.String
readSchemaColumn()
Returns the schema as an XML string.void
refreshTable()
Creates the schema table in the DB.static boolean
run(JDBCConfiguration conf, java.lang.String action)
Run the tool.static boolean
run(JDBCConfiguration conf, java.lang.String[] args, Options opts)
Run the tool.void
setConfiguration(Configuration conf)
Invoked prior to setting bean properties.void
setPrimaryKeyColumn(java.lang.String name)
The name of the primary key column on the schema definition table.void
setSchemaColumn(java.lang.String name)
The name of the schema column on the schema definition table.void
setTable(java.lang.String name)
The name of the schema definition table.void
setTableName(java.lang.String name)
Deprecated.void
startConfiguration()
Invoked before bean property configuration is begun on this object.void
storeSchema(SchemaGroup schema)
Record the schema group after changes may have been made.void
writeSchemaColumn(java.lang.String schema)
Writes the schema as a string to the database.
-
-
-
Field Detail
-
ACTION_ADD
public static final java.lang.String ACTION_ADD
- See Also:
- Constant Field Values
-
ACTION_DROP
public static final java.lang.String ACTION_DROP
- See Also:
- Constant Field Values
-
-
Method Detail
-
getTable
public java.lang.String getTable()
The name of the schema definition table. Defaults toOPENJPA_SCHEMA
.
-
setTable
public void setTable(java.lang.String name)
The name of the schema definition table. Defaults toOPENJPA_SCHEMA
.
-
setTableName
@Deprecated public void setTableName(java.lang.String name)
Deprecated.UsesetTable(java.lang.String)
. Retained for backwards-compatible auto-configuration.
-
setPrimaryKeyColumn
public void setPrimaryKeyColumn(java.lang.String name)
The name of the primary key column on the schema definition table. Defaults toID
.
-
getPrimaryKeyColumn
public java.lang.String getPrimaryKeyColumn()
The name of the primary key column on the schema definition table. Defaults toID
.
-
setSchemaColumn
public void setSchemaColumn(java.lang.String name)
The name of the schema column on the schema definition table. Defaults toSCHEMA_DEF
.
-
getSchemaColumn
public java.lang.String getSchemaColumn()
The name of the schema column on the schema definition table. Defaults toSCHEMA_DEF
.
-
getConfiguration
public JDBCConfiguration getConfiguration()
-
setConfiguration
public void setConfiguration(Configuration conf)
Description copied from interface:Configurable
Invoked prior to setting bean properties.- Specified by:
setConfiguration
in interfaceConfigurable
-
startConfiguration
public void startConfiguration()
Description copied from interface:Configurable
Invoked before bean property configuration is begun on this object.- Specified by:
startConfiguration
in interfaceConfigurable
-
endConfiguration
public void endConfiguration()
Description copied from interface:Configurable
Invoked upon completion of bean property configuration for this object.- Specified by:
endConfiguration
in interfaceConfigurable
-
readSchema
public SchemaGroup readSchema()
Description copied from interface:SchemaFactory
Return the schema group for the current object model and database.- Specified by:
readSchema
in interfaceSchemaFactory
-
storeSchema
public void storeSchema(SchemaGroup schema)
Description copied from interface:SchemaFactory
Record the schema group after changes may have been made.- Specified by:
storeSchema
in interfaceSchemaFactory
- Parameters:
schema
- the schema definition for the entire system
-
refreshTable
public void refreshTable() throws java.sql.SQLException
Creates the schema table in the DB.- Throws:
java.sql.SQLException
-
dropTable
public void dropTable() throws java.sql.SQLException
Drops the sequence table in the DB.- Throws:
java.sql.SQLException
-
readSchemaColumn
public java.lang.String readSchemaColumn() throws java.sql.SQLException
Returns the schema as an XML string.- Throws:
java.sql.SQLException
-
writeSchemaColumn
public void writeSchemaColumn(java.lang.String schema) throws java.sql.SQLException
Writes the schema as a string to the database.- Throws:
java.sql.SQLException
-
main
public static void main(java.lang.String[] args) throws java.io.IOException, java.sql.SQLException
Usage: java org.apache.openjpa.jdbc.schema.TableSchemaFactory [option]* -action/-a <add | drop> Where the following options are recognized.- -properties/-p <properties file or resource>: The
path or resource name of a OpenJPA properties file containing
information such as the license key and connection data as
outlined in
JDBCConfiguration
. Optional. - -<property name> <property value>: All bean
properties of the OpenJPA
JDBCConfiguration
can be set by using their names and supplying a value. For example:-licenseKey adslfja83r3lkadf
- add: Create the schema table.
- drop: Drop the schema table.
- Throws:
java.io.IOException
java.sql.SQLException
- -properties/-p <properties file or resource>: The
path or resource name of a OpenJPA properties file containing
information such as the license key and connection data as
outlined in
-
run
public static boolean run(JDBCConfiguration conf, java.lang.String[] args, Options opts) throws java.io.IOException, java.sql.SQLException
Run the tool. Returns false if invalid options were given.- Throws:
java.io.IOException
java.sql.SQLException
- See Also:
main(java.lang.String[])
-
run
public static boolean run(JDBCConfiguration conf, java.lang.String action) throws java.io.IOException, java.sql.SQLException
Run the tool.- Throws:
java.io.IOException
java.sql.SQLException
-
-