⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compoundprimarykeycolumnspec.java

📁 把java对象映射成数据库表中的一条记录
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

    /**
     * Return the column names (qualified with their table name/alias) of my
     * children. The names are separated by commas.
     *
     * @param tableAlias  a value of type 'String'
     * @return            a value of type 'String'
     */
    public String getFullyQualifiedColumnName(String tableAlias)
    {
        ColumnSpec spec = null;
        StringBuffer buffer = new StringBuffer();
        Iterator iterator = i_columnSpecs.iterator();
        while (iterator.hasNext())
        {
            spec = (ColumnSpec) iterator.next();
            if (tableAlias != null && tableAlias.length() > 0)
            {
                buffer.append(tableAlias);
                buffer.append(".");
            }
            buffer.append(spec.getColumnName());
            if (iterator.hasNext())
            {
                buffer.append(", ");
            }
        }// while
        return buffer.toString();
    }// getFullyQualifiedColumnName(tableAlias)


    /**
     * Return the column names of my children. The names are separated by
     * commas.
     *
     * @return   a value of type 'String'
     */
    public String getColumnName()
    {
        return this.getFullyQualifiedColumnName(null);
    }


    /**
     * Return the SQL values of my children with a comma between each.
     *
     * @param aPO       a value of type 'PersistentObject'
     * @param dbPolicy  a value of type 'DatabasePolicy'
     * @return          a value of type 'String'
     */
    public String getSqlValueFrom(PersistentObject aPO,
            DatabasePolicy dbPolicy)
    {
        ColumnSpec spec = null;
        Iterator iterator = i_columnSpecs.iterator();
        StringBuffer buffer = new StringBuffer();
        while (iterator.hasNext())
        {
            spec = (ColumnSpec) iterator.next();
            buffer.append(spec.getSqlValueFrom(aPO, dbPolicy));
            if (iterator.hasNext())
            {
                buffer.append(", ");
            }
        }// for
        return buffer.toString();
    }


    /**
     * Return something like "id INTEGER, code VARCHAR(999)" for use in a CREATE
     * TABLE statement.
     *
     * @param dbPolicy  a value of type 'DatabasePolicy'
     * @return          a value of type 'String'
     */
    public String columnDefinitionString(DatabasePolicy dbPolicy)
    {
        StringBuffer buffer = new StringBuffer();
        ColumnSpec spec = null;
        Iterator iterator = i_columnSpecs.iterator();
        while (iterator.hasNext())
        {
            spec = (ColumnSpec) iterator.next();
            buffer.append(spec.columnDefinitionString(dbPolicy));
            if (iterator.hasNext())
            {
                buffer.append(", ");
            }
        }// for
        return buffer.toString();
    }


    /**
     * If this is a unique column (or columns), make sure the value doesn't
     * already exist.
     *
     * @param aPO                        a value of type 'PersistentObject'
     * @param helper                     a value of type 'JDBCHelper'
     * @param pkColumnSpec               a value of type 'ColumnSpec'
     * @param dbPolicy                   a value of type 'DatabasePolicy'
     * @param tableName                  a value of type 'String'
     * @exception DuplicateRowException  if an error occurs
     */
    public void validateUnique(PersistentObject aPO,
            JDBCHelper helper,
            ColumnSpec pkColumnSpec,
            DatabasePolicy dbPolicy,
            String tableName)
        throws DuplicateRowException
    {
        AbstractColumnSpec.validateUnique(aPO,
                helper,
                pkColumnSpec,
                this,
                dbPolicy,
                tableName);
    }


    /**
     * Build a string that represents a name/value pair
     *
     * @param pkOrPersistentObject  a primary key value or a PersistentObject
     * @param separator             usually "="
     * @param tableName             name of the table
     * @param dbPolicy              a value of type 'DatabasePolicy'
     * @return                      The built name-value pair
     */
    public String buildNameValuePair(Object pkOrPersistentObject,
            String separator,
            String tableName,
            DatabasePolicy dbPolicy)
    {
        throw new RuntimeException("This method should not be used.");
    }

    /**
     * Sets the ValueTo attribute of the CompoundPrimaryKeyColumnSpec object
     *
     * @param aValue  The new ValueTo value
     * @param aPO     The new ValueTo value
     */
    public void setValueTo(Object aValue,
            PersistentObject aPO)
    {
        throw new RuntimeException("This method should not be used.");
    }

    /**
     * Gets the ValueFrom attribute of the CompoundPrimaryKeyColumnSpec object
     *
     * @param aPO  Description of Parameter
     * @return     The value of ValueFrom
     */
    public Object getValueFrom(PersistentObject aPO)
    {
        throw new RuntimeException("This method should not be used.");
    }

    /**
     * Description of the Method
     *
     * @param obj       Description of Parameter
     * @param dbPolicy  Description of Parameter
     * @return          Description of the Returned Value
     */
    public String formatForSql(Object obj, DatabasePolicy dbPolicy)
    {
        throw new RuntimeException("This method should not be used.");
    }

    /**
     * Gets the ColumnValueFrom attribute of the CompoundPrimaryKeyColumnSpec
     * object
     *
     * @param helper            a JDBCHelper
     * @return                  The value of ColumnValueFrom
     * @exception SQLException  If SQLException is thrown by the JDBC driver.
     */
    public Object getColumnValueFrom(JDBCHelper helper)
        throws SQLException
    {
        throw new RuntimeException("This method should not be used.");
    }

    /**
     * Gets the ColumnClass attribute of the CompoundPrimaryKeyColumnSpec object
     *
     * @return   The value of ColumnClass
     */
    public Class getColumnClass()
    {
        throw new RuntimeException("This method should not be used.");
    }

    /**
     * Gets the Getter attribute of the CompoundPrimaryKeyColumnSpec object
     *
     * @return   The value of Getter
     */
    public String getGetter()
    {
        throw new RuntimeException("This method should not be used.");
    }

    /**
     * Gets the Setter attribute of the CompoundPrimaryKeyColumnSpec object
     *
     * @return   The value of Setter
     */
    public String getSetter()
    {
        throw new RuntimeException("This method should not be used.");
    }

    /**
     * Gets the Required attribute of the CompoundPrimaryKeyColumnSpec object
     *
     * @return   The value of Required
     */
    public boolean isRequired()
    {
        return true;
    }

    /**
     * Gets the SequencedPrimaryKey attribute of the
     * CompoundPrimaryKeyColumnSpec object
     *
     * @return   The value of SequencedPrimaryKey
     */
    public boolean isSequencedPrimaryKey()
    {
        return false;
    }

    /**
     * Gets the NaturalPrimaryKey attribute of the CompoundPrimaryKeyColumnSpec
     * object
     *
     * @return   The value of NaturalPrimaryKey
     */
    public boolean isNaturalPrimaryKey()
    {
        return true;
    }

    /**
     * Gets the SubtypeIdentifier attribute of the CompoundPrimaryKeyColumnSpec
     * object
     *
     * @return   The value of SubtypeIdentifier
     */
    public boolean isSubtypeIdentifier()
    {
        return false;
    }

    /**
     * Gets the PrimaryKey attribute of the CompoundPrimaryKeyColumnSpec object
     *
     * @return   The value of PrimaryKey
     */
    public boolean isPrimaryKey()
    {
        return true;
    }

    /**
     * Gets the Unique attribute of the CompoundPrimaryKeyColumnSpec object
     *
     * @return   The value of Unique
     */
    public boolean isUnique()
    {
        return true;
    }

    /**
     * Gets the Default attribute of the CompoundPrimaryKeyColumnSpec object
     *
     * @return   The value of Default
     */
    public Object getDefault()
    {
        throw new RuntimeException("This method should not be used.");
    }

    /**
     * Gets the OptimisticLock attribute of the CompoundPrimaryKeyColumnSpec
     * object
     *
     * @return   The value of OptimisticLock
     */
    public boolean isOptimisticLock()
    {
        return false;
    }

    /**
     * Sets the Required attribute of the CompoundPrimaryKeyColumnSpec object
     *
     * @param b  The new Required value
     */
    public void setRequired(boolean b)
    {
    }

}// CompoundPrimaryKeyColumnSpec




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -