Top Description Fields Constructors Methods
org.eclipse.persistence.tools.schemaframework

public Class StoredProcedureGenerator

extends Object
Class Inheritance
Imports
java.io.IOException, .StringWriter, .Writer, java.sql.Time, java.util.ArrayList, .Enumeration, .Hashtable, .Iterator, .List, .Map, .Vector, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.exceptions.ValidationException, org.eclipse.persistence.internal.databaseaccess.DatasourceCall, org.eclipse.persistence.internal.expressions.ParameterExpression, org.eclipse.persistence.internal.helper.DatabaseField, .Helper, org.eclipse.persistence.internal.queries.CallQueryMechanism, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, org.eclipse.persistence.mappings.DatabaseMapping, .OneToManyMapping, org.eclipse.persistence.queries.DatabaseQuery, .DeleteAllQuery, .DeleteObjectQuery, .InsertObjectQuery, .ReadAllQuery, .ReadObjectQuery, .SQLCall, .UpdateObjectQuery, org.eclipse.persistence.sequencing.TableSequence, org.eclipse.persistence.sessions.DatabaseLogin, .DatabaseRecord

Purpose: To generate StoredProcedures from EclipseLink Projects

Description: This Class was designed to read in a project and produce StoredProcedures. It then modifies the descriptors files of the project to use these StoredProcedures.

Note

reads are not supported in Oracle.

Responsibilities:

Author
Gordon Yorke
Since
TopLink 2.1

Field Summary

Modifier and TypeField and Description
private static final String
private Hashtable<Integer, Class<?>>
private Hashtable<ClassDescriptor, Hashtable<String, Hashtable<String, StoredProcedureDefinition>>>
mappingStoredProcedures

This hashtable is used to store the storedProcedure referenced by the mapping name.

private static final int
private String
public SchemaManager
private Hashtable<String, StoredProcedureDefinition>
private Hashtable<ClassDescriptor, Vector<StoredProcedureDefinition>>
storedProcedures

This hashtable is used to store the storedProcedure referenced by the class name.

private Writer

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
buildIntToTypeConverterHash()

INTERNAL: Build all conversions based on JDBC return values.

protected String
buildProcedureString(SQLCall call)

INTERNAL: Given a call, this method produces the stored procedure string based on the SQL string inside the call.

public void
generateAmendmentClass(Writer outputWriter, String packageName, String className)

PUBLIC: Generate an amendment class that will set up the descriptors to use these stored procedures.

protected StoredProcedureDefinition
generateDeleteStoredProcedure(ClassDescriptor descriptor)

INTERNAL: Generates the delete stored procedure for this descriptor

protected StoredProcedureDefinition
generateInsertStoredProcedure(ClassDescriptor descriptor)

INTERNAL: Generates the insert stored procedure for this descriptor

protected Hashtable<String, Hashtable<String, StoredProcedureDefinition>>
generateMappingStoredProcedures(ClassDescriptor descriptor)

INTERNAL: Generates the mapping stored procedures for this descriptor.

protected StoredProcedureDefinition
generateObjectStoredProcedure(DatabaseQuery query, List<DatabaseField> fields, String namePrefix)

INTERNAL: Generates the object level stored procedure based on the passed in query

protected StoredProcedureDefinition
generateOneToManyMappingDeleteAllProcedure(OneToManyMapping mapping)

INTERNAL: Generates the delete all stored procedure for this mapping

protected StoredProcedureDefinition
generateOneToManyMappingProcedures(OneToManyMapping mapping, DatabaseQuery query, Map<DatabaseField, DatabaseField> fields, String namePrefix)

INTERNAL: Generates all the stored procedures for this mapping

protected StoredProcedureDefinition
generateOneToManyMappingReadProcedure(OneToManyMapping mapping)

INTERNAL: Generates the read all stored procedure for this mapping

protected StoredProcedureDefinition
generateReadAllStoredProcedure(ClassDescriptor descriptor)

INTERNAL: Generates the read all stored procedure for this descriptor

protected StoredProcedureDefinition
generateReadStoredProcedure(ClassDescriptor descriptor)

INTERNAL: Generates the read stored procedure for this descriptor

protected void
generateSequenceStoredProcedures(Project project)

INTERNAL: Generates the select and update stored procedures for this project.

protected StoredProcedureDefinition
generateStoredProcedure(DatabaseQuery query, List<DatabaseField> fields, String name)

INTERNAL: Generates the stored procedure for this query.

protected StoredProcedureDefinition
generateStoredProcedure(DatabaseQuery query, List<DatabaseField> fields, AbstractRecord rowForPrepare, String name)

INTERNAL: Generates the stored procedure for this query using the row passed in for the check prepare.

public void
generateStoredProcedures()

PUBLIC: generates all the stored procedures using the schema manager.

public void
generateStoredProcedures(Writer writerOrNull)

PUBLIC: generates all the stored procedures to the writer using the schema manager outputDDLToWriter(Writer).

protected StoredProcedureDefinition
generateUpdateStoredProcedure(ClassDescriptor descriptor)

INTERNAL: Generates the update stored procedure for this descriptor

protected String
getFieldName(String argumentName)

INTERNAL: return the original field name based on the argument name.

protected Class<?>
getFieldType(Object jdbcDataType)

INTERNAL: return the class corresponding to the passed in JDBC type.

public String
public AbstractSession
public Writer
public void
setPrefix(String prefix)

protected void
verify()

INTERNAL: Verify that this project and descriptors do not have optimistic locking.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_PREFIXback to summary
private static final String DEFAULT_PREFIX
intToTypeConverterHashback to summary
private Hashtable<Integer, Class<?>> intToTypeConverterHash
mappingStoredProceduresback to summary
private Hashtable<ClassDescriptor, Hashtable<String, Hashtable<String, StoredProcedureDefinition>>> mappingStoredProcedures

This hashtable is used to store the storedProcedure referenced by the mapping name.

MAX_NAME_SIZEback to summary
private static final int MAX_NAME_SIZE
prefixback to summary
private String prefix
schemaManagerback to summary
public SchemaManager schemaManager
sequenceProceduresback to summary
private Hashtable<String, StoredProcedureDefinition> sequenceProcedures
storedProceduresback to summary
private Hashtable<ClassDescriptor, Vector<StoredProcedureDefinition>> storedProcedures

This hashtable is used to store the storedProcedure referenced by the class name.

writerback to summary
private Writer writer

Constructor Detail

StoredProcedureGeneratorback to summary
public StoredProcedureGenerator(SchemaManager schemaMngr)

Method Detail

buildIntToTypeConverterHashback to summary
protected void buildIntToTypeConverterHash()

INTERNAL: Build all conversions based on JDBC return values.

buildProcedureStringback to summary
protected String buildProcedureString(SQLCall call)

INTERNAL: Given a call, this method produces the stored procedure string based on the SQL string inside the call.

generateAmendmentClassback to summary
public void generateAmendmentClass(Writer outputWriter, String packageName, String className) throws ValidationException

PUBLIC: Generate an amendment class that will set up the descriptors to use these stored procedures.

generateDeleteStoredProcedureback to summary
protected StoredProcedureDefinition generateDeleteStoredProcedure(ClassDescriptor descriptor)

INTERNAL: Generates the delete stored procedure for this descriptor

generateInsertStoredProcedureback to summary
protected StoredProcedureDefinition generateInsertStoredProcedure(ClassDescriptor descriptor)

INTERNAL: Generates the insert stored procedure for this descriptor

generateMappingStoredProceduresback to summary
protected Hashtable<String, Hashtable<String, StoredProcedureDefinition>> generateMappingStoredProcedures(ClassDescriptor descriptor)

INTERNAL: Generates the mapping stored procedures for this descriptor. currently only 1:1 and 1:M are supported

generateObjectStoredProcedureback to summary
protected StoredProcedureDefinition generateObjectStoredProcedure(DatabaseQuery query, List<DatabaseField> fields, String namePrefix)

INTERNAL: Generates the object level stored procedure based on the passed in query

generateOneToManyMappingDeleteAllProcedureback to summary
protected StoredProcedureDefinition generateOneToManyMappingDeleteAllProcedure(OneToManyMapping mapping)

INTERNAL: Generates the delete all stored procedure for this mapping

generateOneToManyMappingProceduresback to summary
protected StoredProcedureDefinition generateOneToManyMappingProcedures(OneToManyMapping mapping, DatabaseQuery query, Map<DatabaseField, DatabaseField> fields, String namePrefix)

INTERNAL: Generates all the stored procedures for this mapping

generateOneToManyMappingReadProcedureback to summary
protected StoredProcedureDefinition generateOneToManyMappingReadProcedure(OneToManyMapping mapping)

INTERNAL: Generates the read all stored procedure for this mapping

generateReadAllStoredProcedureback to summary
protected StoredProcedureDefinition generateReadAllStoredProcedure(ClassDescriptor descriptor)

INTERNAL: Generates the read all stored procedure for this descriptor

generateReadStoredProcedureback to summary
protected StoredProcedureDefinition generateReadStoredProcedure(ClassDescriptor descriptor)

INTERNAL: Generates the read stored procedure for this descriptor

generateSequenceStoredProceduresback to summary
protected void generateSequenceStoredProcedures(Project project)

INTERNAL: Generates the select and update stored procedures for this project. no procedures are generated for native sequencing.

Note

reads are not supported in Oracle.

generateStoredProcedureback to summary
protected StoredProcedureDefinition generateStoredProcedure(DatabaseQuery query, List<DatabaseField> fields, String name)

INTERNAL: Generates the stored procedure for this query. A new row will be used for the check prepare.

generateStoredProcedureback to summary
protected StoredProcedureDefinition generateStoredProcedure(DatabaseQuery query, List<DatabaseField> fields, AbstractRecord rowForPrepare, String name)

INTERNAL: Generates the stored procedure for this query using the row passed in for the check prepare.

generateStoredProceduresback to summary
public void generateStoredProcedures()

PUBLIC: generates all the stored procedures using the schema manager. The schema manager may be set to write directly to the database on the a file. See outputDDLToWriter(Writer) and outputDDLToDatabase() on SchemaManager

generateStoredProceduresback to summary
public void generateStoredProcedures(Writer writerOrNull)

PUBLIC: generates all the stored procedures to the writer using the schema manager outputDDLToWriter(Writer).

generateUpdateStoredProcedureback to summary
protected StoredProcedureDefinition generateUpdateStoredProcedure(ClassDescriptor descriptor)

INTERNAL: Generates the update stored procedure for this descriptor

getFieldNameback to summary
protected String getFieldName(String argumentName)

INTERNAL: return the original field name based on the argument name.

getFieldTypeback to summary
protected Class<?> getFieldType(Object jdbcDataType)

INTERNAL: return the class corresponding to the passed in JDBC type.

getPrefixback to summary
public String getPrefix()
getSessionback to summary
public AbstractSession getSession()
getWriterback to summary
public Writer getWriter()
setPrefixback to summary
public void setPrefix(String prefix)
verifyback to summary
protected void verify() throws ValidationException

INTERNAL: Verify that this project and descriptors do not have optimistic locking.

writeDefinitionback to summary
public void writeDefinition(StoredProcedureDefinition definition)