Search in sources :

Example 21 with DfProcedureColumnMeta

use of org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta in project dbflute-core by dbflute.

the class DfPmbMetaData method needsPostgreSQLByteaHandling.

public boolean needsPostgreSQLByteaHandling(String propertyName) {
    assertArgumentPmbMetaDataPropertyName(propertyName);
    final DfProcedureColumnMeta metaInfo = getProcedureColumnInfo(propertyName);
    return metaInfo != null && _columnHandler.isPostgreSQLBytea(metaInfo.getDbTypeName());
}
Also used : DfProcedureColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta)

Example 22 with DfProcedureColumnMeta

use of org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta in project dbflute-core by dbflute.

the class DfPmbMetaData method needsOracleArrayHandling.

public boolean needsOracleArrayHandling(String propertyName) {
    assertArgumentPmbMetaDataPropertyName(propertyName);
    if (!getBasicProperties().isDatabaseOracle() || !getLittleAdjustmentProperties().isAvailableDatabaseNativeJDBC()) {
        return false;
    }
    final DfProcedureColumnMeta metaInfo = getProcedureColumnInfo(propertyName);
    return metaInfo != null && metaInfo.hasTypeArrayInfo();
}
Also used : DfProcedureColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta)

Example 23 with DfProcedureColumnMeta

use of org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta in project dbflute-core by dbflute.

the class DfPmbMetaData method needsBytesBlobHandling.

public boolean needsBytesBlobHandling(String propertyName) {
    assertArgumentPmbMetaDataPropertyName(propertyName);
    final DfProcedureColumnMeta metaInfo = getProcedureColumnInfo(propertyName);
    return metaInfo != null && _columnHandler.isConceptTypeBytesBlob(metaInfo.getDbTypeName());
}
Also used : DfProcedureColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta)

Example 24 with DfProcedureColumnMeta

use of org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta in project dbflute-core by dbflute.

the class DfPmbMetaData method getProcedureParameterOracleStructTypeName.

public String getProcedureParameterOracleStructTypeName(String propertyName) {
    assertArgumentPmbMetaDataPropertyName(propertyName);
    final DfProcedureColumnMeta columnInfo = getProcedureColumnInfo(propertyName);
    if (columnInfo != null && columnInfo.hasTypeStructInfo()) {
        return columnInfo.getTypeStructInfo().getTypeSqlName();
    }
    return "";
}
Also used : DfProcedureColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta)

Example 25 with DfProcedureColumnMeta

use of org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta in project dbflute-core by dbflute.

the class DfProcedureExtractor method setupProcedureColumnMetaInfo.

protected void setupProcedureColumnMetaInfo(DfProcedureMeta procedureMetaInfo, ResultSet columnRs) throws SQLException {
    final Set<String> uniqueSet = new HashSet<String>();
    while (columnRs.next()) {
        // /- - - - - - - - - - - - - - - - - - - - - - - -
        // same policy as table process about JDBC handling
        // (see DfTableHandler.java)
        // - - - - - - - - - -/
        final String columnName = columnRs.getString("COLUMN_NAME");
        // because Oracle package procedure may return them
        if (uniqueSet.contains(columnName)) {
            continue;
        }
        uniqueSet.add(columnName);
        final Integer procedureColumnType;
        {
            final String columnType = columnRs.getString("COLUMN_TYPE");
            final int unknowType = DatabaseMetaData.procedureColumnUnknown;
            if (Srl.is_NotNull_and_NotTrimmedEmpty(columnType)) {
                procedureColumnType = toInt("columnType", columnType);
            } else {
                procedureColumnType = unknowType;
            }
        }
        final int jdbcType;
        {
            int tmpJdbcType = Types.OTHER;
            String dataType = null;
            try {
                dataType = columnRs.getString("DATA_TYPE");
            } catch (RuntimeException ignored) {
                // pinpoint patch
                // for example, SQLServer throws an exception
                // if the procedure is a function that returns table type
                final String procdureName = procedureMetaInfo.getProcedureFullQualifiedName();
                log("*Failed to get data type: " + procdureName + "." + columnName);
                tmpJdbcType = Types.OTHER;
            }
            if (Srl.is_NotNull_and_NotTrimmedEmpty(dataType)) {
                tmpJdbcType = toInt("dataType", dataType);
            }
            jdbcType = tmpJdbcType;
        }
        final String dbTypeName = columnRs.getString("TYPE_NAME");
        // uses getString() to get null value
        // (getInt() returns zero when a value is no defined)
        final Integer columnSize;
        {
            final String precision = columnRs.getString("PRECISION");
            if (Srl.is_NotNull_and_NotTrimmedEmpty(precision)) {
                columnSize = toInt("precision", precision);
            } else {
                final String length = columnRs.getString("LENGTH");
                if (Srl.is_NotNull_and_NotTrimmedEmpty(length)) {
                    columnSize = toInt("length", length);
                } else {
                    columnSize = null;
                }
            }
        }
        final Integer decimalDigits;
        {
            final String scale = columnRs.getString("SCALE");
            if (Srl.is_NotNull_and_NotTrimmedEmpty(scale)) {
                decimalDigits = toInt("scale", scale);
            } else {
                decimalDigits = null;
            }
        }
        final String columnComment = columnRs.getString("REMARKS");
        final DfProcedureColumnMeta procedureColumnMetaInfo = new DfProcedureColumnMeta();
        procedureColumnMetaInfo.setColumnName(columnName);
        if (procedureColumnType == DatabaseMetaData.procedureColumnUnknown) {
            procedureColumnMetaInfo.setProcedureColumnType(DfProcedureColumnType.procedureColumnUnknown);
        } else if (procedureColumnType == DatabaseMetaData.procedureColumnIn) {
            procedureColumnMetaInfo.setProcedureColumnType(DfProcedureColumnType.procedureColumnIn);
        } else if (procedureColumnType == DatabaseMetaData.procedureColumnInOut) {
            procedureColumnMetaInfo.setProcedureColumnType(DfProcedureColumnType.procedureColumnInOut);
        } else if (procedureColumnType == DatabaseMetaData.procedureColumnOut) {
            procedureColumnMetaInfo.setProcedureColumnType(DfProcedureColumnType.procedureColumnOut);
        } else if (procedureColumnType == DatabaseMetaData.procedureColumnReturn) {
            procedureColumnMetaInfo.setProcedureColumnType(DfProcedureColumnType.procedureColumnReturn);
        } else if (procedureColumnType == DatabaseMetaData.procedureColumnResult) {
            procedureColumnMetaInfo.setProcedureColumnType(DfProcedureColumnType.procedureColumnResult);
        } else {
            throw new IllegalStateException("Unknown procedureColumnType: " + procedureColumnType);
        }
        procedureColumnMetaInfo.setJdbcDefType(jdbcType);
        procedureColumnMetaInfo.setDbTypeName(dbTypeName);
        procedureColumnMetaInfo.setColumnSize(columnSize);
        procedureColumnMetaInfo.setDecimalDigits(decimalDigits);
        procedureColumnMetaInfo.setColumnComment(columnComment);
        procedureMetaInfo.addProcedureColumn(procedureColumnMetaInfo);
    }
    adjustProcedureColumnList(procedureMetaInfo);
}
Also used : DfProcedureColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

DfProcedureColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta)27 DfProcedureColumnType (org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta.DfProcedureColumnType)5 DfProcedureMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)5 LinkedHashSet (java.util.LinkedHashSet)2 DfProcedureNotParamResultMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureNotParamResultMeta)2 CallableStatement (java.sql.CallableStatement)1 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 HashSet (java.util.HashSet)1 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)1 DfProcedureExecutionMetaGettingFailureException (org.dbflute.exception.DfProcedureExecutionMetaGettingFailureException)1 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)1 DfColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfColumnMeta)1 DfProcedureArgumentInfo (org.dbflute.logic.jdbc.metadata.info.DfProcedureArgumentInfo)1 DfProcedureType (org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta.DfProcedureType)1 DfTypeArrayInfo (org.dbflute.logic.jdbc.metadata.info.DfTypeArrayInfo)1 DfTypeStructInfo (org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo)1 DfPmbMetaData (org.dbflute.logic.sql2entity.pmbean.DfPmbMetaData)1 DfOutsideSqlProperties (org.dbflute.properties.DfOutsideSqlProperties)1