當前位置: 首頁>>代碼示例>>Java>>正文


Java JdbcType類代碼示例

本文整理匯總了Java中org.apache.ibatis.type.JdbcType的典型用法代碼示例。如果您正苦於以下問題:Java JdbcType類的具體用法?Java JdbcType怎麽用?Java JdbcType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JdbcType類屬於org.apache.ibatis.type包,在下文中一共展示了JdbcType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setNonNullParameter

import org.apache.ibatis.type.JdbcType; //導入依賴的package包/類
@Override
public void setNonNullParameter(PreparedStatement ps, int i, Map parameter, JdbcType jdbcType) throws SQLException {
    if (parameter != null && parameter.size() > 0) {
        LOGGER.debug("Input-Map before serializing: ", parameter);
        // Convert Map to byte array
        try (ByteArrayOutputStream byteOut = new ByteArrayOutputStream()) {
            ObjectOutputStream out = new ObjectOutputStream(byteOut);
            out.writeObject(parameter);
            ps.setBlob(i, new ByteArrayInputStream(byteOut.toByteArray()));
            out.close();
        } catch (IOException e) {
            LOGGER.error("During serialization of 'customAttributes' an error occured: ", e);
        }
    } else {
        ps.setNull(i, Types.BLOB);
    }
}
 
開發者ID:Taskana,項目名稱:taskana,代碼行數:18,代碼來源:MapTypeHandler.java

示例2: setNonNullParameter

import org.apache.ibatis.type.JdbcType; //導入依賴的package包/類
@Override
public void setNonNullParameter(PreparedStatement ps, int i, Object[] parameter,
                                JdbcType jdbcType) throws SQLException {

    String typeName = null;
    if (parameter instanceof Integer[]) {
        typeName = TYPE_NAME_INTEGER;
    } else if (parameter instanceof String[]) {
        typeName = TYPE_NAME_VARCHAR;
    } else if (parameter instanceof Boolean[]) {
        typeName = TYPE_NAME_BOOLEAN;
    } else if (parameter instanceof Double[]) {
        typeName = TYPE_NAME_NUMERIC;
    }

    if (typeName == null) {
        throw new TypeException("ArrayTypeHandler parameter typeName error, your type is " + parameter.getClass().getName());
    }

    // 這3行是關鍵的代碼,創建Array,然後ps.setArray(i, array)就可以了
    Connection conn = ps.getConnection();
    Array array = conn.createArrayOf(typeName, parameter);
    ps.setArray(i, array);
}
 
開發者ID:ling49043171,項目名稱:mark-framework,代碼行數:25,代碼來源:ArrayTypeHandler.java

示例3: prepareInsertAuthorMappedStatement

import org.apache.ibatis.type.JdbcType; //導入依賴的package包/類
public static MappedStatement prepareInsertAuthorMappedStatement(final Configuration config) {
  final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
  MappedStatement ms = new MappedStatement.Builder(config, "insertAuthor", new StaticSqlSource(config,"INSERT INTO author (id,username,password,email,bio,favourite_section) values(?,?,?,?,?,?)"), SqlCommandType.INSERT)
      .parameterMap(
          new ParameterMap.Builder(
              config, "defaultParameterMap", Author.class,
              new ArrayList<ParameterMapping>() {
                {
                  add(new ParameterMapping.Builder(config, "id", registry.getTypeHandler(int.class)).build());
                  add(new ParameterMapping.Builder(config, "username", registry.getTypeHandler(String.class)).build());
                  add(new ParameterMapping.Builder(config, "password", registry.getTypeHandler(String.class)).build());
                  add(new ParameterMapping.Builder(config, "email", registry.getTypeHandler(String.class)).build());
                  add(new ParameterMapping.Builder(config, "bio", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).build());
                  add(new ParameterMapping.Builder(config, "favouriteSection", registry.getTypeHandler(Section.class)).jdbcType(JdbcType.VARCHAR).build());
                }
              }).build())
      .cache(authorCache).build();
  return ms;
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:20,代碼來源:ExecutorTestHelper.java

示例4: prepareSelectAuthorViaOutParams

import org.apache.ibatis.type.JdbcType; //導入依賴的package包/類
public static MappedStatement prepareSelectAuthorViaOutParams(final Configuration config) {
  final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
  MappedStatement ms = new MappedStatement.Builder(config, "selectAuthorViaOutParams", new StaticSqlSource(config, "{call selectAuthorViaOutParams(?,?,?,?,?)}"), SqlCommandType.SELECT)
      .statementType(StatementType.CALLABLE)
      .parameterMap(new ParameterMap.Builder(config, "defaultParameterMap", Author.class,
          new ArrayList<ParameterMapping>() {
            {
              add(new ParameterMapping.Builder(config, "id", registry.getTypeHandler(int.class)).build());
              add(new ParameterMapping.Builder(config, "username", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).mode(ParameterMode.OUT).build());
              add(new ParameterMapping.Builder(config, "password", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).mode(ParameterMode.OUT).build());
              add(new ParameterMapping.Builder(config, "email", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).mode(ParameterMode.OUT).build());
              add(new ParameterMapping.Builder(config, "bio", registry.getTypeHandler(String.class)).jdbcType(JdbcType.VARCHAR).mode(ParameterMode.OUT).build());
            }
          }).build())
      .resultMaps(new ArrayList<ResultMap>())
      .cache(authorCache).build();
  return ms;
}
 
開發者ID:txazo,項目名稱:mybatis,代碼行數:19,代碼來源:ExecutorTestHelper.java

示例5: parameterMapElement

import org.apache.ibatis.type.JdbcType; //導入依賴的package包/類
private void parameterMapElement(List<XNode> list) throws Exception {
    for (XNode parameterMapNode : list) {
        String id = parameterMapNode.getStringAttribute("id");
        String type = parameterMapNode.getStringAttribute("type");
        Class<?> parameterClass = resolveClass(type);
        List<XNode> parameterNodes = parameterMapNode.evalNodes("parameter");
        List<ParameterMapping> parameterMappings = new ArrayList<>();
        for (XNode parameterNode : parameterNodes) {
            String property = parameterNode.getStringAttribute("property");
            String javaType = parameterNode.getStringAttribute("javaType");
            String jdbcType = parameterNode.getStringAttribute("jdbcType");
            String resultMap = parameterNode.getStringAttribute("resultMap");
            String mode = parameterNode.getStringAttribute("mode");
            String typeHandler = parameterNode.getStringAttribute("typeHandler");
            Integer numericScale = parameterNode.getIntAttribute("numericScale");
            ParameterMode modeEnum = resolveParameterMode(mode);
            Class<?> javaTypeClass = resolveClass(javaType);
            JdbcType jdbcTypeEnum = resolveJdbcType(jdbcType);
            @SuppressWarnings("unchecked")
            Class<? extends TypeHandler<?>> typeHandlerClass = (Class<? extends TypeHandler<?>>) resolveClass(typeHandler);
            ParameterMapping parameterMapping = builderAssistant.buildParameterMapping(parameterClass, property, javaTypeClass, jdbcTypeEnum, resultMap, modeEnum, typeHandlerClass, numericScale);
            parameterMappings.add(parameterMapping);
        }
        builderAssistant.addParameterMap(id, parameterClass, parameterMappings);
    }
}
 
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:27,代碼來源:MybatisXMLMapperBuilder.java

示例6: processDiscriminatorElement

import org.apache.ibatis.type.JdbcType; //導入依賴的package包/類
private Discriminator processDiscriminatorElement(XNode context, Class<?> resultType, List<ResultMapping> resultMappings) throws Exception {
    String column = context.getStringAttribute("column");
    String javaType = context.getStringAttribute("javaType");
    String jdbcType = context.getStringAttribute("jdbcType");
    String typeHandler = context.getStringAttribute("typeHandler");
    Class<?> javaTypeClass = resolveClass(javaType);
    @SuppressWarnings("unchecked")
    Class<? extends TypeHandler<?>> typeHandlerClass = (Class<? extends TypeHandler<?>>) resolveClass(typeHandler);
    JdbcType jdbcTypeEnum = resolveJdbcType(jdbcType);
    Map<String, String> discriminatorMap = new HashMap<>();
    for (XNode caseChild : context.getChildren()) {
        String value = caseChild.getStringAttribute("value");
        String resultMap = caseChild.getStringAttribute("resultMap", processNestedResultMappings(caseChild, resultMappings));
        discriminatorMap.put(value, resultMap);
    }
    return builderAssistant.buildDiscriminator(resultType, column, javaTypeClass, jdbcTypeEnum, typeHandlerClass, discriminatorMap);
}
 
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:18,代碼來源:MybatisXMLMapperBuilder.java

示例7: buildResultMappingFromContext

import org.apache.ibatis.type.JdbcType; //導入依賴的package包/類
private ResultMapping buildResultMappingFromContext(XNode context, Class<?> resultType, List<ResultFlag> flags) throws Exception {
    String property;
    if (flags.contains(ResultFlag.CONSTRUCTOR)) {
        property = context.getStringAttribute("name");
    } else {
        property = context.getStringAttribute("property");
    }
    String column = context.getStringAttribute("column");
    String javaType = context.getStringAttribute("javaType");
    String jdbcType = context.getStringAttribute("jdbcType");
    String nestedSelect = context.getStringAttribute("select");
    String nestedResultMap = context.getStringAttribute("resultMap",
            processNestedResultMappings(context, Collections.<ResultMapping>emptyList()));
    String notNullColumn = context.getStringAttribute("notNullColumn");
    String columnPrefix = context.getStringAttribute("columnPrefix");
    String typeHandler = context.getStringAttribute("typeHandler");
    String resultSet = context.getStringAttribute("resultSet");
    String foreignColumn = context.getStringAttribute("foreignColumn");
    boolean lazy = "lazy".equals(context.getStringAttribute("fetchType", configuration.isLazyLoadingEnabled() ? "lazy" : "eager"));
    Class<?> javaTypeClass = resolveClass(javaType);
    @SuppressWarnings("unchecked")
    Class<? extends TypeHandler<?>> typeHandlerClass = (Class<? extends TypeHandler<?>>) resolveClass(typeHandler);
    JdbcType jdbcTypeEnum = resolveJdbcType(jdbcType);
    return builderAssistant.buildResultMapping(resultType, property, column, javaTypeClass, jdbcTypeEnum, nestedSelect, nestedResultMap, notNullColumn, columnPrefix, typeHandlerClass, flags, resultSet, foreignColumn, lazy);
}
 
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:26,代碼來源:MybatisXMLMapperBuilder.java

示例8: applyDiscriminator

import org.apache.ibatis.type.JdbcType; //導入依賴的package包/類
private Discriminator applyDiscriminator(String resultMapId, Class<?> resultType, TypeDiscriminator discriminator) {
    if (discriminator != null) {
        String column = discriminator.column();
        Class<?> javaType = discriminator.javaType() == void.class ? String.class : discriminator.javaType();
        JdbcType jdbcType = discriminator.jdbcType() == JdbcType.UNDEFINED ? null : discriminator.jdbcType();
        @SuppressWarnings("unchecked")
        Class<? extends TypeHandler<?>> typeHandler = (Class<? extends TypeHandler<?>>) (discriminator.typeHandler() == UnknownTypeHandler.class ? null
                : discriminator.typeHandler());
        Case[] cases = discriminator.cases();
        Map<String, String> discriminatorMap = new HashMap<>();
        for (Case c : cases) {
            String value = c.value();
            String caseResultMapId = resultMapId + "-" + value;
            discriminatorMap.put(value, caseResultMapId);
        }
        return assistant.buildDiscriminator(resultType, column, javaType, jdbcType, typeHandler, discriminatorMap);
    }
    return null;
}
 
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:20,代碼來源:MybatisMapperAnnotationBuilder.java

示例9: typeHandlerElement

import org.apache.ibatis.type.JdbcType; //導入依賴的package包/類
private void typeHandlerElement(XNode parent) throws Exception {
    if (parent != null) {
        for (XNode child : parent.getChildren()) {
            if ("package".equals(child.getName())) {
                String typeHandlerPackage = child.getStringAttribute("name");
                typeHandlerRegistry.register(typeHandlerPackage);
            } else {
                String javaTypeName = child.getStringAttribute("javaType");
                String jdbcTypeName = child.getStringAttribute("jdbcType");
                String handlerTypeName = child.getStringAttribute("handler");
                Class<?> javaTypeClass = resolveClass(javaTypeName);
                JdbcType jdbcType = resolveJdbcType(jdbcTypeName);
                Class<?> typeHandlerClass = resolveClass(handlerTypeName);
                if (javaTypeClass != null) {
                    if (jdbcType == null) {
                        typeHandlerRegistry.register(javaTypeClass, typeHandlerClass);
                    } else {
                        typeHandlerRegistry.register(javaTypeClass, jdbcType, typeHandlerClass);
                    }
                } else {
                    typeHandlerRegistry.register(typeHandlerClass);
                }
            }
        }
    }
}
 
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:27,代碼來源:MybatisXMLConfigBuilder.java

示例10: setParameter

import org.apache.ibatis.type.JdbcType; //導入依賴的package包/類
public void setParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException
{
    if (parameter == null)
    {
        ps.setNull(i, SerializableTypeHandler.serializableType);
    }
    else
    {
        try
        {
            ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(parameter);
            byte[] bytes = baos.toByteArray();
            ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
            ps.setBinaryStream(i, bais, bytes.length);
        }
        catch (Throwable e)
        {
            throw new SerializationException(e);
        }
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:24,代碼來源:SerializableTypeHandler.java

示例11: setParameter

import org.apache.ibatis.type.JdbcType; //導入依賴的package包/類
public void setParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException
{
    if (parameter == null)
    {
        ps.setNull(i, Types.BINARY);
    }
    else
    {
        try
        {
            ps.setBytes(i, (byte[])parameter);
        }
        catch (Throwable e)
        {
            throw new SerializationException(e);
        }
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:19,代碼來源:ByteArrayTypeHandler.java

示例12: findAttachmentsByTaskId

import org.apache.ibatis.type.JdbcType; //導入依賴的package包/類
@Select("SELECT ID, TASK_ID, CREATED, MODIFIED, CLASSIFICATION_KEY, REF_COMPANY, REF_SYSTEM, REF_INSTANCE, REF_TYPE, REF_VALUE, CHANNEL, RECEIVED, CUSTOM_ATTRIBUTES "
    + "FROM ATTACHMENT "
    + "WHERE TASK_ID = #{taskId}")
@Results(value = {
    @Result(property = "id", column = "ID"),
    @Result(property = "taskId", column = "TASK_ID"),
    @Result(property = "created", column = "CREATED"),
    @Result(property = "modified", column = "MODIFIED"),
    @Result(property = "classification", column = "CLASSIFICATION_KEY", javaType = Classification.class,
        one = @One(select = CLASSIFICATION_FINDBYID)),
    @Result(property = "objectReference.company", column = "REF_COMPANY"),
    @Result(property = "objectReference.system", column = "REF_SYSTEM"),
    @Result(property = "objectReference.systemInstance", column = "REF_INSTANCE"),
    @Result(property = "objectReference.type", column = "REF_TYPE"),
    @Result(property = "objectReference.value", column = "REF_VALUE"),
    @Result(property = "channel", column = "CHANNEL"),
    @Result(property = "received", column = "RECEIVED"),
    @Result(property = "customAttributes", column = "CUSTOM_ATTRIBUTES", jdbcType = JdbcType.BLOB,
        javaType = Map.class, typeHandler = MapTypeHandler.class),
})
List<AttachmentImpl> findAttachmentsByTaskId(@Param("taskId") String taskId);
 
開發者ID:Taskana,項目名稱:taskana,代碼行數:22,代碼來源:AttachmentMapper.java

示例13: select

import org.apache.ibatis.type.JdbcType; //導入依賴的package包/類
@Select({
        "select",
        "u.id, u.name, u.email, u.creator, u.flag, u.last_login_time,c.name createUser",
        "from admin_user u LEFT JOIN admin_user c ON u.creator=c.id",
        "where u.name LIKE #{query} LIMIT #{begin},#{pagesize}"
})
@Results({
        @Result(column="id", property="id", jdbcType= JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType= JdbcType.VARCHAR),
        @Result(column="psw", property="psw", jdbcType= JdbcType.VARCHAR),
        @Result(column="email", property="email", jdbcType= JdbcType.VARCHAR),
        @Result(column="creator", property="creator", jdbcType= JdbcType.INTEGER),
        @Result(column="flag", property="flag", jdbcType= JdbcType.INTEGER),
        @Result(column="last_login_time", property="lastLoginTime", jdbcType= JdbcType.TIMESTAMP)
})
List<AdminUser> select(@Param("begin") int begin, @Param("pagesize") int pageSize, @Param("query") String query);
 
開發者ID:RayeWang,項目名稱:easyadmin,代碼行數:17,代碼來源:AdminUserMapper.java

示例14: selectByExample

import org.apache.ibatis.type.JdbcType; //導入依賴的package包/類
@SelectProvider(type=MenuSqlProvider.class, method="selectByExample")
@Results({
    @Result(column="id", property="id", jdbcType= JdbcType.INTEGER, id=true),
    @Result(column="name", property="name", jdbcType= JdbcType.VARCHAR),
    @Result(column="url", property="url", jdbcType= JdbcType.VARCHAR),
    @Result(column="icon", property="icon", jdbcType= JdbcType.VARCHAR),
    @Result(column="menu_type", property="menuType", jdbcType= JdbcType.CHAR),
    @Result(column="display", property="display", jdbcType= JdbcType.INTEGER),
    @Result(column="parent_id", property="parentId", jdbcType= JdbcType.INTEGER),
    @Result(column="creator", property="creator", jdbcType= JdbcType.INTEGER),
    @Result(column="create_time", property="createTime", jdbcType= JdbcType.TIMESTAMP),
    @Result(column="update_user", property="updateUser", jdbcType= JdbcType.INTEGER),
    @Result(column="update_time", property="updateTime", jdbcType= JdbcType.TIMESTAMP),
    @Result(column="status", property="status", jdbcType= JdbcType.CHAR)
})
List<Menu> selectByExample(MenuCriteria example);
 
開發者ID:RayeWang,項目名稱:easyadmin,代碼行數:17,代碼來源:MenuMapper.java

示例15: applyDiscriminator

import org.apache.ibatis.type.JdbcType; //導入依賴的package包/類
private Discriminator applyDiscriminator(String resultMapId, Class<?> resultType, TypeDiscriminator discriminator) {
  if (discriminator != null) {
    String column = discriminator.column();
    Class<?> javaType = discriminator.javaType() == void.class ? String.class : discriminator.javaType();
    JdbcType jdbcType = discriminator.jdbcType() == JdbcType.UNDEFINED ? null : discriminator.jdbcType();
    @SuppressWarnings("unchecked")
    Class<? extends TypeHandler<?>> typeHandler = (Class<? extends TypeHandler<?>>)
            (discriminator.typeHandler() == UnknownTypeHandler.class ? null : discriminator.typeHandler());
    Case[] cases = discriminator.cases();
    Map<String, String> discriminatorMap = new HashMap<String, String>();
    for (Case c : cases) {
      String value = c.value();
      String caseResultMapId = resultMapId + "-" + value;
      discriminatorMap.put(value, caseResultMapId);
    }
    return assistant.buildDiscriminator(resultType, column, javaType, jdbcType, typeHandler, discriminatorMap);
  }
  return null;
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:20,代碼來源:MapperAnnotationBuilder.java


注:本文中的org.apache.ibatis.type.JdbcType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。