Search in sources :

Example 26 with ValueType

use of org.dbflute.jdbc.ValueType in project dbflute-core by dbflute.

the class TnAbstractPropertyTypeFactory method findValueTypeByName.

protected ValueType findValueTypeByName(String propertyName, Class<?> propertyType, String keyName) {
    final ValueType valueType = TnValueTypes.getPluginValueType(keyName);
    if (valueType != null) {
        return valueType;
    }
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Not found the plug-in value type by the name.");
    br.addItem("Bean Type");
    br.addElement(_beanClass.getName());
    br.addItem("Property");
    br.addElement(propertyName);
    br.addElement(propertyType.getName());
    br.addItem("Key Name");
    br.addElement(keyName);
    final String msg = br.buildExceptionMessage();
    throw new PluginValueTypeNotFoundException(msg);
}
Also used : ValueType(org.dbflute.jdbc.ValueType) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) PluginValueTypeNotFoundException(org.dbflute.exception.PluginValueTypeNotFoundException)

Example 27 with ValueType

use of org.dbflute.jdbc.ValueType in project dbflute-core by dbflute.

the class TnProcedureValueTypeProvider method findValueTypeByName.

// ===================================================================================
// By Name
// =======
protected ValueType findValueTypeByName(Class<?> pmbType, String paramName, Class<?> paramType, String keyName) {
    final ValueType valueType = TnValueTypes.getPluginValueType(keyName);
    if (valueType != null) {
        return valueType;
    }
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Not found a plug-in value type by the name.");
    br.addItem("ProcedurePmb");
    br.addElement(pmbType.getName());
    br.addItem("Parameter");
    br.addElement(paramName);
    br.addElement(paramType.getName());
    br.addItem("Key Name");
    br.addElement(keyName);
    final String msg = br.buildExceptionMessage();
    throw new PluginValueTypeNotFoundException(msg);
}
Also used : ValueType(org.dbflute.jdbc.ValueType) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) PluginValueTypeNotFoundException(org.dbflute.exception.PluginValueTypeNotFoundException)

Example 28 with ValueType

use of org.dbflute.jdbc.ValueType in project dbflute-core by dbflute.

the class DfLReverseDataExtractor method processNormalData.

// ===================================================================================
// Normal Data
// ===========
protected DfLReverseDataResult processNormalData(Table table, List<String> sqlList) {
    final DfJdbcFacade facade = createJdbcFacade();
    final Map<String, ValueType> valueTypeMap = createColumnValueTypeMap(table.getColumnList());
    final DfJFadStringConverter converter = createStringConverter();
    final Integer limit = _extractingLimit;
    final List<Map<String, String>> resultList = facade.selectStringList(sqlList, valueTypeMap, converter, limit);
    return new DfLReverseDataResult(resultList);
}
Also used : DfJFadStringConverter(org.dbflute.helper.jdbc.facade.DfJFadStringConverter) ValueType(org.dbflute.jdbc.ValueType) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) DfJdbcFacade(org.dbflute.helper.jdbc.facade.DfJdbcFacade)

Example 29 with ValueType

use of org.dbflute.jdbc.ValueType in project dbflute-core by dbflute.

the class TnProcedureHandler method handleOutParameter.

/**
 * Handle result set for out-parameter.
 * @param conn The connection for the database. (NotNull)
 * @param cs The statement of procedure. (NotNull)
 * @param pmb The parameter bean from arguments. (NotNull)
 * @param executed The return value of execute() that means whether the first result is a result set.
 * @throws SQLException When it fails to handle the SQL.
 */
protected void handleOutParameter(Connection conn, CallableStatement cs, Object pmb, boolean executed) throws SQLException {
    if (pmb == null) {
        return;
    }
    int index = 0;
    for (TnProcedureParameterType ppt : _procedureMetaData.getBindParameterTypeList()) {
        final ValueType valueType = ppt.getValueType();
        if (ppt.isOutType()) {
            Object value = valueType.getValue(cs, index + 1);
            if (value instanceof ResultSet) {
                final ResultSet rs = wrapResultSetIfNeeds(pmb, (ResultSet) value);
                final TnResultSetHandler handler = createResultSetHandler(pmb, ppt);
                try {
                    value = handler.handle(rs);
                } finally {
                    if (rs != null) {
                        rs.close();
                    }
                }
            }
            ppt.setValue(pmb, value);
        }
        ++index;
    }
}
Also used : ValueType(org.dbflute.jdbc.ValueType) ResultSet(java.sql.ResultSet) TnFetchAssistResultSet(org.dbflute.s2dao.jdbc.TnFetchAssistResultSet) TnResultSetHandler(org.dbflute.s2dao.jdbc.TnResultSetHandler) TnProcedureParameterType(org.dbflute.s2dao.metadata.TnProcedureParameterType)

Example 30 with ValueType

use of org.dbflute.jdbc.ValueType in project dbflute-core by dbflute.

the class TnCommandContextHandler method bindFirstScope.

// ===================================================================================
// Bind Scope
// ==========
protected int bindFirstScope(Connection conn, PreparedStatement ps, Object[] bindVariables, Class<?>[] bindVariableTypes) {
    final List<Object> firstVariableList = new ArrayList<Object>();
    final List<ValueType> firstValueTypeList = new ArrayList<ValueType>();
    int index = 0;
    for (TnPropertyType propertyType : _firstBoundPropTypeList) {
        firstVariableList.add(bindVariables[index]);
        firstValueTypeList.add(propertyType.getValueType());
        ++index;
    }
    bindArgs(conn, ps, firstVariableList.toArray(), firstValueTypeList.toArray(new ValueType[0]));
    return index;
}
Also used : ValueType(org.dbflute.jdbc.ValueType) ArrayList(java.util.ArrayList) TnPropertyType(org.dbflute.s2dao.metadata.TnPropertyType)

Aggregations

ValueType (org.dbflute.jdbc.ValueType)35 MockValueType (org.dbflute.mock.MockValueType)8 LinkedHashMap (java.util.LinkedHashMap)6 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 ResultSet (java.sql.ResultSet)4 SQLException (java.sql.SQLException)4 DfJFadStringConverter (org.dbflute.helper.jdbc.facade.DfJFadStringConverter)4 DfJdbcFacade (org.dbflute.helper.jdbc.facade.DfJdbcFacade)4 Entry (java.util.Map.Entry)3 TnPropertyType (org.dbflute.s2dao.metadata.TnPropertyType)3 Connection (java.sql.Connection)2 Statement (java.sql.Statement)2 Timestamp (java.sql.Timestamp)2 Column (org.apache.torque.engine.database.model.Column)2 SQLExceptionResource (org.dbflute.bhv.exception.SQLExceptionResource)2 PluginValueTypeNotFoundException (org.dbflute.exception.PluginValueTypeNotFoundException)2 StringKeyMap (org.dbflute.helper.StringKeyMap)2 DfJFadCursorCallback (org.dbflute.helper.jdbc.facade.DfJFadCursorCallback)2 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)2