FileDocCategorySizeDatePackage
TableSequenceDefinition.javaAPI DocGlassfish v2 API7011Tue May 22 16:54:54 BST 2007oracle.toplink.essentials.tools.schemaframework

TableSequenceDefinition

public class TableSequenceDefinition extends SequenceDefinition

Purpose: Allow a generic way of creating sequences on the different platforms, and allow optional parameters to be specified.

Fields Summary
public String
sequenceTableName
Hold the name of the sequence table
public String
sequenceNameFieldName
Hold the name of the column in the sequence table which specifies the sequence name
public String
sequenceCounterFieldName
Hold the name of the column in the sequence table which specifies the sequence numeric value
public int
initialValue
Constructors Summary
public TableSequenceDefinition(String name, String sequenceTableName, String sequenceNameFieldName, String sequenceCounterFieldName, int initialValue)


               
        super(name);
        setSequenceTableName(sequenceTableName);
        setSequenceCounterFieldName(sequenceCounterFieldName);
        setSequenceNameFieldName(sequenceNameFieldName);
        setInitialValue(initialValue);
    
public TableSequenceDefinition(TableSequence sequence)

        this(sequence.getName(), sequence.getTableName(), sequence.getNameFieldName(), sequence.getCounterFieldName(), sequence.getInitialValue());
    
public TableSequenceDefinition(String name, TableSequence sequence)

        this(name, sequence.getTableName(), sequence.getNameFieldName(), sequence.getCounterFieldName(), sequence.getInitialValue());
    
Methods Summary
public java.io.WriterbuildCreationWriter(oracle.toplink.essentials.internal.sessions.AbstractSession session, java.io.Writer writer)
INTERNAL: Return the SQL required to insert the sequence row into the sequence table. Assume that the sequence table exists.

        try {
            writer.write("INSERT INTO ");
            writer.write(getSequenceTableName());
            writer.write("(" + getSequenceNameFieldName());
            writer.write(", " + getSequenceCounterFieldName());
            writer.write(") values (");
            writer.write("'" + getName() + "', "  + initialValue + ")");
        } catch (IOException ioException) {
            throw ValidationException.fileError(ioException);
        }
        return writer;
    
public java.io.WriterbuildDeletionWriter(oracle.toplink.essentials.internal.sessions.AbstractSession session, java.io.Writer writer)
INTERNAL: Return the SQL to delete the row from the sequence table.

        try {
            writer.write("DELETE FROM ");
            writer.write(getSequenceTableName());
            writer.write(" WHERE " + getSequenceNameFieldName());
            writer.write(" = '" + getName() + "'");
        } catch (IOException ioException) {
            throw ValidationException.fileError(ioException);
        }
        return writer;
    
public oracle.toplink.essentials.tools.schemaframework.TableDefinitionbuildTableDefinition()
INTERNAL: Return a TableDefinition specifying sequence table.

        TableDefinition definition = new TableDefinition();
        definition.setName(getSequenceTableName());
        definition.addPrimaryKeyField(getSequenceNameFieldName(), String.class, 50);
        definition.addField(getSequenceCounterFieldName(), BigDecimal.class);
        return definition;
    
public booleancheckIfExist(oracle.toplink.essentials.internal.sessions.AbstractSession session)
INTERAL: Execute the SQL required to insert the sequence row into the sequence table. Assume that the sequence table exists.

        Vector results = session.executeSelectingCall(new oracle.toplink.essentials.queryframework.SQLCall("SELECT * FROM " + getSequenceTableName() + " WHERE " + getSequenceNameFieldName() + " = '" + getName() + "'"));
        return !results.isEmpty();
    
public java.lang.StringgetSequenceCounterFieldName()
PUBLIC:

        return sequenceCounterFieldName;
    
public java.lang.StringgetSequenceNameFieldName()
PUBLIC:

        return sequenceNameFieldName;
    
public java.lang.StringgetSequenceTableName()
PUBLIC:

        return sequenceTableName;
    
public voidsetInitialValue(int initialValue)
PUBLIC:

        this.initialValue = initialValue;
    
public voidsetSequenceCounterFieldName(java.lang.String sequenceCounterFieldName)
PUBLIC:

        this.sequenceCounterFieldName = sequenceCounterFieldName;
    
public voidsetSequenceNameFieldName(java.lang.String sequenceNameFieldName)
PUBLIC:

        this.sequenceNameFieldName = sequenceNameFieldName;
    
public voidsetSequenceTableName(java.lang.String sequenceTableName)
PUBLIC:

        this.sequenceTableName = sequenceTableName;