FileDocCategorySizeDatePackage
TableSequence.javaAPI DocGlassfish v2 API6822Tue May 22 16:54:52 BST 2007oracle.toplink.essentials.sequencing

TableSequence

public class TableSequence extends QuerySequence

Purpose:

Fields Summary
protected static final String
defaultTableName
Default sequence table name
protected DatabaseTable
table
Hold the database table
protected String
counterFieldName
Hold the name of the column in the sequence table which specifies the sequence numeric value
protected String
nameFieldName
Hold the name of the column in the sequence table which specifies the sequence name
protected String
qualifier
Constructors Summary
public TableSequence()


      
        super(false, true);
        setTableName(defaultTableName);
    
public TableSequence(String name)

        super(name, false, true);
        setTableName(defaultTableName);
    
public TableSequence(String name, int size)

        super(name, size, false, true);
        setTableName(defaultTableName);
    
public TableSequence(String name, int size, int initialValue)

        super(name, size, initialValue, false, true);
        setTableName(defaultTableName);
    
public TableSequence(String name, String tableName)

        this(name);
        setTableName(tableName);
    
public TableSequence(String name, String tableName, String nameFieldName, String counterFieldName)

        this(name);
        setTableName(tableName);
        setNameFieldName(nameFieldName);
        setCounterFieldName(counterFieldName);
    
public TableSequence(String name, int size, String tableName)

        this(name, size);
        setTableName(tableName);
    
public TableSequence(String name, int size, String tableName, String nameFieldName, String counterFieldName)

        this(name, size);
        setTableName(tableName);
        setNameFieldName(nameFieldName);
        setCounterFieldName(counterFieldName);
    
Methods Summary
protected oracle.toplink.essentials.queryframework.ValueReadQuerybuildSelectQuery()

        ValueReadQuery query = new ValueReadQuery();
        query.addArgument(getNameFieldName());
        StringWriter writer = new StringWriter();
        writer.write("SELECT " + getCounterFieldName());
        writer.write(" FROM " + getQualifiedTableName());
        writer.write(" WHERE " + getNameFieldName());
        writer.write(" = #" + getNameFieldName());
        query.setSQLString(writer.toString());

        return query;
    
protected oracle.toplink.essentials.queryframework.DataModifyQuerybuildUpdateQuery()

        DataModifyQuery query = new DataModifyQuery();
        query.addArgument(getNameFieldName());
        query.addArgument("PREALLOC_SIZE");
        StringWriter writer = new StringWriter();
        writer.write("UPDATE " + getQualifiedTableName());
        writer.write(" SET " + getCounterFieldName());
        writer.write(" = " + getCounterFieldName());
        writer.write(" + #PREALLOC_SIZE");
        writer.write(" WHERE " + getNameFieldName() + " = #" + getNameFieldName());
        query.setSQLString(writer.toString());

        return query;
    
public booleanequals(java.lang.Object obj)

        if (obj instanceof TableSequence) {
            TableSequence other = (TableSequence)obj;
            if (equalNameAndSize(this, other)) {
                return getTableName().equals(other.getTableName()) && getCounterFieldName().equals(other.getCounterFieldName()) && getNameFieldName().equals(other.getNameFieldName());
            } else {
                return false;
            }
        } else {
            return false;
        }
    
public java.lang.StringgetCounterFieldName()

        return counterFieldName;
    
public java.lang.StringgetNameFieldName()

        return nameFieldName;
    
public java.lang.StringgetQualifiedTableName()

        if (qualifier.equals("")) {
            return getTableName();
        } else {
            return qualifier + "." + getTableName();
        }
    
public oracle.toplink.essentials.internal.helper.DatabaseTablegetTable()

        return table;
    
public java.lang.StringgetTableName()

        return getTable().getQualifiedName();
    
public voidonConnect()
INTERNAL:

        super.onConnect();
        qualifier = getDatasourcePlatform().getTableQualifier();
    
public voidonDisconnect()
INTERNAL:

        qualifier = "";
        super.onDisconnect();
    
public voidsetCounterFieldName(java.lang.String name)

        counterFieldName = name;
    
public voidsetNameFieldName(java.lang.String name)

        nameFieldName = name;
    
public voidsetTable(oracle.toplink.essentials.internal.helper.DatabaseTable table)

        this.table = table;
    
public voidsetTableName(java.lang.String name)

        table = new DatabaseTable(name);