mybatis的类型转换器TypeHandler

【人工智能之深度学习】12. BERT微调实战:医疗文本分类的领域自适应技巧与工业级实现 摘要:医疗文本分类是自然语言处理在医疗健康领域的核心应用,可辅助疾病诊断、病历结构化和医疗质量监控。然而,医疗文本的专业术语密集、实体关系复杂及数据长尾分布等特性,导致通用BERT模型性能受限。本文系统阐述医疗文本分类的领域自适应技术,从理论原理到工业级实现展开全流程讲解。首先分析医疗文本的独特属性及技术挑战;随后详解领域继续预训练、适配器微调、对抗训练等核心技术的数学原理;构建包含数据预处理、模型优化、隐私保护的完整实战架构;通过疾病分类、情感分析、事件检测三大案例验证技术有效性。 阅读详情

TypeHandler简介

在Mybatis中可以定义一个TypeHandler类型,通过它可以实现Java类型跟数据库类型的相互转换。

TypeHandler接口

public interface TypeHandler<T> {

  void setParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException;

  /**
   * Gets the result.
   *
   * @param rs
   *          the rs
   * @param columnName
   *          Colunm name, when configuration <code>useColumnLabel</code> is <code>false</code>
   * @return the result
   * @throws SQLException
   *           the SQL exception
   */
  T getResult(ResultSet rs, String columnName) throws SQLException;

  T getResult(ResultSet rs, int columnIndex) throws SQLException;

  T getResult(CallableStatement cs, int columnIndex) throws SQLException;
}

typeHandler接口实现了4个方法,熟悉jdbc应该从方法定义就可以看懂这写接口方法的意思。
不过多解释了,如果不熟悉还是多写写原生jdbc

Mybatis还为我们提供一个实现了TypeHandler接口的抽象类BaseTypeHandler。所以我们也可以通过继承BaseTypeHandler来实现自己的TypeHandler。

  // 继承TypeReference主要提供了一个方法用来获取父类的泛型类型
public abstract class BaseTypeHandler<T> extends TypeReference<T> implements TypeHandler<T> {

  /**
   * @deprecated Since 3.5.0 - See https://github.com/mybatis/mybatis-3/issues/1203. This field will remove future.
   */
  @Deprecated
  protected Configuration configuration;

  /**
   * Sets the configuration.
   *
   * @param c
   *          the new configuration
   * @deprecated Since 3.5.0 - See https://github.com/mybatis/mybatis-3/issues/1203. This property will remove future.
   */
  @Deprecated
  public void setConfiguration(Configuration c) {
    this.configuration = c;
  }

  @Override
  public void setParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException {
    if (parameter == null) {
      if (jdbcType == null) {
        throw new TypeException("JDBC requires that the JdbcType must be specified for all nullable parameters.");
      }
      try {
        ps.setNull(i, jdbcType.TYPE_CODE);
      } catch (SQLException e) {
        throw new TypeException("Error setting null for parameter #" + i + " with JdbcType " + jdbcType + " . "
              + "Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. "
              + "Cause: " + e, e);
      }
    } else {
      try {
        setNonNullParameter(ps, i, parameter, jdbcType);
      } catch (Exception e) {
        throw new TypeException("Error setting non null for parameter #" + i + " with JdbcType " + jdbcType + " . "
              + "Try setting a different JdbcType for this parameter or a different configuration property. "
              + "Cause: " + e, e);
      }
    }
  }

  @Override
  public T getResult(ResultSet rs, String columnName) throws SQLException {
    try {
      return getNullableResult(rs, columnName);
    } catch (Exception e) {
      throw new ResultMapException("Error attempting to get column '" + columnName + "' from result set.  Cause: " + e, e);
    }
  }

  @Override
  public T getResult(ResultSet rs, int columnIndex) throws SQLException {
    try {
      return getNullableResult(rs, columnIndex);
    } catch (Exception e) {
      throw new ResultMapException("Error attempting to get column #" + columnIndex + " from result set.  Cause: " + e, e);
    }
  }

  @Override
  public T getResult(CallableStatement cs, int columnIndex) throws SQLException {
    try {
      return getNullableResult(cs, columnIndex);
    } catch (Exception e) {
      throw new ResultMapException("Error attempting to get column #" + columnIndex + " from callable statement.  Cause: " + e, e);
    }
  }

  public abstract void setNonNullParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException;

  /**
   * Gets the nullable result.
   *
   * @param rs
   *          the rs
   * @param columnName
   *          Colunm name, when configuration <code>useColumnLabel</code> is <code>false</code>
   * @return the nullable result
   * @throws SQLException
   *           the SQL exception
   */
  public abstract T getNullableResult(ResultSet rs, String columnName) throws SQLException;

  public abstract T getNullableResult(ResultSet rs, int columnIndex) throws SQLException;

  public abstract T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException;

}

public abstract class TypeReference<T> {

  private final Type rawType;
//子类调用父类构造器时调用getSuperclassTypeParameter方法获取rawType
  protected TypeReference() {
    rawType = getSuperclassTypeParameter(getClass());
  }

  Type getSuperclassTypeParameter(Class<?> clazz) {
  // 主要为获取父类泛型及父类类型,Type是接口实现类是ParameterizedTypeImpl
    Type genericSuperclass = clazz.getGenericSuperclass();
    if (genericSuperclass instanceof Class) {
      // try to climb up the hierarchy until meet something useful
      if (TypeReference.class != genericSuperclass) {
        return getSuperclassTypeParameter(clazz.getSuperclass());
      }

      throw new TypeException("'" + getClass() + "' extends TypeReference but misses the type parameter. "
        + "Remove the extension or add a type parameter to it.");
    }
	// 获取泛型类型,如
    Type rawType = ((ParameterizedType) genericSuperclass).getActualTypeArguments()[0];
    // TODO remove this when Reflector is fixed to return Types
    if (rawType instanceof ParameterizedType) {
      rawType = ((ParameterizedType) rawType).getRawType();
    }

    return rawType;
  }

  public final Type getRawType() {
    return rawType;
  }

  @Override
  public String toString() {
    return rawType.toString();
  }

}

在这里插入图片描述
在这里插入图片描述

自定义TypeHandler类型

1、定义表结构

CREATE TABLE dept (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(255) DEFAULT NULL,
loc varchar(255) DEFAULT NULL,
list varchar(255) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

pom以来

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>parent-mybatis</artifactId>
        <groupId>org.example</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>mybatis-demo1</artifactId>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.5.5</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.49</version>
        </dependency>


        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>RELEASE</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

</project>

2、定义实体

package com.lhl.demo1;


import java.util.List;

public class Dept {

  

    private int id;

    private String name;

    private String loc;

    private List<String> list;

    public List<String> getList() {
        return list;
    }

    public Dept setList(List<String> list) {
        this.list = list;
        return this;
    }

    public int getId() {
        return id;
    }

    public Dept setId(int id) {
        this.id = id;
        return this;
    }

    public String getName() {
        return name;
    }

    public Dept setName(String name) {
        this.name = name;
        return this;
    }

    public String getLoc() {
        return loc;
    }

    public Dept setLoc(String loc) {
        this.loc = loc;
        return this;
    }
    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Dept{");
        sb.append("id=").append(id);
        sb.append(", name='").append(name).append('\'');
        sb.append(", loc='").append(loc).append('\'');
        sb.append(", list=").append(list);
        sb.append('}');
        return sb.toString();
    }
}

3、mybatis配置文件及mapper文件

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    <typeHandlers>

        <typeHandler handler="com.lhl.demo1.MyTypeHandler" javaType="List" jdbcType="VARCHAR"></typeHandler>
    </typeHandlers>

    <environments default="development">
        <environment id="development">
            <transactionManager type="JDBC"/>
            <dataSource type="POOLED">
                <property name="driver" value="com.mysql.jdbc.Driver"/>
                <property name="url" value="jdbc:mysql://localhost:3306/mybatis-test"/>
                <property name="username" value="root"/>
                <property name="password" value="123456"/>
            </dataSource>
        </environment>
    </environments>
    <mappers>
        <mapper resource="DeptMapper.xml"/>
    </mappers>
</configuration>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lhl.demo1.DeptMapper">
    <insert id="insertDept">
        insert into dept(name, loc, list)
         // 配置typeHandler
        values (#{name}, #{loc}, #{list,javaType=List,jdbcType=VARCHAR,typeHandler=com.lhl.demo1.MyTypeHandler})
    </insert>

 // 配置typeHandler
    <resultMap id="selectDeptMap" type="com.lhl.demo1.Dept">
        <result column="list" property="list" typeHandler="com.lhl.demo1.MyTypeHandler"></result>
    </resultMap>
    <select id="selectDept" resultMap="selectDeptMap">
        select *
        from dept
    </select>
   
  
    </resultMap>

</mapper>

mapper接口

package com.lhl.demo1;

import java.util.List;


public interface DeptMapper {

    void insertDept();

    public List<Dept> selectDept();

}

自定义TypeHandler写法

package com.lhl.demo1;

import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;


@MappedJdbcTypes(JdbcType.VARCHAR)
@MappedTypes(List.class)
public class MyTypeHandler extends BaseTypeHandler<List> {

    @Override
    public void setNonNullParameter(PreparedStatement ps, int i, List parameter, JdbcType jdbcType) throws SQLException {
        String  str = String.valueOf(parameter.stream().collect(Collectors.joining(",")));
        ps.setString(i,str);
    }

    @Override
    public List getNullableResult(ResultSet rs, String columnName) throws SQLException {
        String result = rs.getString(columnName);
        return Arrays.asList(result.split(","));
    }

    @Override
    public List getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
        return null;
    }

    @Override
    public List getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
        return null;
    }
}

1.@MappedJdbcTypes定义是JdbcType类型,必须要是枚举类org.apache.ibatis.type.JdbcType所枚举的数据类型

2.@MappedTypes定义的是JavaType的数据类型,描述哪些Java类型可被拦截。

将TypeHandler注册到mybatis中

<!--需要在别名标签之后-->
  <typeHandlers>

        <typeHandler handler="com.lhl.demo1.MyTypeHandler" javaType="List" jdbcType="VARCHAR"></typeHandler>
    </typeHandlers>
<!--或者通过包扫描的方式,注册包下所有的TypeHandler-->
<typeHandlers>
        <package name="com.lhl.demo1"/>
    </typeHandlers>

在Mapper中配置

 <insert id="insertDept">
        insert into dept(name, loc, list)
         // 配置typeHandler
        values (#{name}, #{loc}, #{list,javaType=List,jdbcType=VARCHAR,typeHandler=com.lhl.demo1.MyTypeHandler})
    </insert>
    
 // 配置typeHandler
    <resultMap id="selectDeptMap" type="com.lhl.demo1.Dept">
        <result column="list" property="list" typeHandler="com.lhl.demo1.MyTypeHandler"></result>
    </resultMap>
    <select id="selectDept" resultMap="selectDeptMap">
        select *
        from dept
    </select>

测试类

package com.lhl.demo1;

import org.apache.ibatis.executor.result.DefaultResultHandler;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;


public class Test01 {
    SqlSession sqlSession = null;

    @BeforeEach
    public void before(){

        String resource = "mybatis-config.xml";
        InputStream inputStream = null;
        try {
            inputStream = Resources.getResourceAsStream(resource);
        } catch (IOException e) {
            e.printStackTrace();
        }
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        sqlSession = sqlSessionFactory.openSession();
    }

    @Test
    public void test1(){
        Dept dept =new Dept();
        dept.setLoc("湖北");
        dept.setName("金融事业单位");
        dept.setList(Arrays.asList("1","2","3333"));
        int insertDept = sqlSession.insert("insertDept", dept);
        sqlSession.commit();
    }

    @Test
    public void test2(){

        DeptMapper mapper = sqlSession.getMapper(DeptMapper.class);
        System.out.println(mapper.selectDept());
    }


}

插入时的结果
在这里插入图片描述
查询结果:
在这里插入图片描述

TypeHandlerRegistry

自定义的TypeHandler起作用主要依赖TypeHandlerRegistry进行注册
register方法定义了一部分mybatis自己的类型转换方式,自己实现的typeHandler最终也是调用的register方法来进行注册的。
如:register(List.class,new MyTypeHandler() );
register(JdbcType.VARCHAR,new MyTypeHandler() );
对应到@MappedJdbcTypes(JdbcType.VARCHAR)
@MappedTypes(List.class)

 register(Boolean.class, new BooleanTypeHandler());
    register(boolean.class, new BooleanTypeHandler());
    register(JdbcType.BOOLEAN, new BooleanTypeHandler());
    register(JdbcType.BIT, new BooleanTypeHandler());

    register(Byte.class, new ByteTypeHandler());
    register(byte.class, new ByteTypeHandler());
    register(JdbcType.TINYINT, new ByteTypeHandler());

    register(Short.class, new ShortTypeHandler());
    register(short.class, new ShortTypeHandler());
    register(JdbcType.SMALLINT, new ShortTypeHandler());

    register(Integer.class, new IntegerTypeHandler());
    register(int.class, new IntegerTypeHandler());
    register(JdbcType.INTEGER, new IntegerTypeHandler());

    register(Long.class, new LongTypeHandler());
    register(long.class, new LongTypeHandler());

    register(Float.class, new FloatTypeHandler());
    register(float.class, new FloatTypeHandler());
    register(JdbcType.FLOAT, new FloatTypeHandler());

    register(Double.class, new DoubleTypeHandler());
    register(double.class, new DoubleTypeHandler());
    register(JdbcType.DOUBLE, new DoubleTypeHandler());

    register(Reader.class, new ClobReaderTypeHandler());
    register(String.class, new StringTypeHandler());
    register(String.class, JdbcType.CHAR, new StringTypeHandler());
    register(String.class, JdbcType.CLOB, new ClobTypeHandler());
    register(String.class, JdbcType.VARCHAR, new StringTypeHandler());
    register(String.class, JdbcType.LONGVARCHAR, new StringTypeHandler());
    register(String.class, JdbcType.NVARCHAR, new NStringTypeHandler());
    register(String.class, JdbcType.NCHAR, new NStringTypeHandler());
    register(String.class, JdbcType.NCLOB, new NClobTypeHandler());
    register(JdbcType.CHAR, new StringTypeHandler());
    register(JdbcType.VARCHAR, new StringTypeHandler());
    register(JdbcType.CLOB, new ClobTypeHandler());
    register(JdbcType.LONGVARCHAR, new StringTypeHandler());
    register(JdbcType.NVARCHAR, new NStringTypeHandler());
    register(JdbcType.NCHAR, new NStringTypeHandler());
    register(JdbcType.NCLOB, new NClobTypeHandler());

    register(Object.class, JdbcType.ARRAY, new ArrayTypeHandler());
    register(JdbcType.ARRAY, new ArrayTypeHandler());

    register(BigInteger.class, new BigIntegerTypeHandler());
    register(JdbcType.BIGINT, new LongTypeHandler());

    register(BigDecimal.class, new BigDecimalTypeHandler());
    register(JdbcType.REAL, new BigDecimalTypeHandler());
    register(JdbcType.DECIMAL, new BigDecimalTypeHandler());
    register(JdbcType.NUMERIC, new BigDecimalTypeHandler());

    register(InputStream.class, new BlobInputStreamTypeHandler());
    register(Byte[].class, new ByteObjectArrayTypeHandler());
    register(Byte[].class, JdbcType.BLOB, new BlobByteObjectArrayTypeHandler());
    register(Byte[].class, JdbcType.LONGVARBINARY, new BlobByteObjectArrayTypeHandler());
    register(byte[].class, new ByteArrayTypeHandler());
    register(byte[].class, JdbcType.BLOB, new BlobTypeHandler());
    register(byte[].class, JdbcType.LONGVARBINARY, new BlobTypeHandler());
    register(JdbcType.LONGVARBINARY, new BlobTypeHandler());
    register(JdbcType.BLOB, new BlobTypeHandler());

    register(Object.class, unknownTypeHandler);
    register(Object.class, JdbcType.OTHER, unknownTypeHandler);
    register(JdbcType.OTHER, unknownTypeHandler);

    register(Date.class, new DateTypeHandler());
    register(Date.class, JdbcType.DATE, new DateOnlyTypeHandler());
    register(Date.class, JdbcType.TIME, new TimeOnlyTypeHandler());
    register(JdbcType.TIMESTAMP, new DateTypeHandler());
    register(JdbcType.DATE, new DateOnlyTypeHandler());
    register(JdbcType.TIME, new TimeOnlyTypeHandler());

    register(java.sql.Date.class, new SqlDateTypeHandler());
    register(java.sql.Time.class, new SqlTimeTypeHandler());
    register(java.sql.Timestamp.class, new SqlTimestampTypeHandler());

    register(String.class, JdbcType.SQLXML, new SqlxmlTypeHandler());

    register(Instant.class, new InstantTypeHandler());
    register(LocalDateTime.class, new LocalDateTimeTypeHandler());
    register(LocalDate.class, new LocalDateTypeHandler());
    register(LocalTime.class, new LocalTimeTypeHandler());
    register(OffsetDateTime.class, new OffsetDateTimeTypeHandler());
    register(OffsetTime.class, new OffsetTimeTypeHandler());
    register(ZonedDateTime.class, new ZonedDateTimeTypeHandler());
    register(Month.class, new MonthTypeHandler());
    register(Year.class, new YearTypeHandler());
    register(YearMonth.class, new YearMonthTypeHandler());
    register(JapaneseDate.class, new JapaneseDateTypeHandler());

    // issue #273
    register(Character.class, new CharacterTypeHandler());
    register(char.class, new CharacterTypeHandler());
ssm框架搭建 这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载 立即下载

相关推荐

Grey Hack v0.7.3618 保姆级教程:手把手教你用metaxploit.so写一个自动提权脚本

本文详细介绍了如何在Grey Hack v0.7.3618中使用metaxploit.so库编写自动化提权脚本。从环境准备到核心功能解析,再到漏洞利用链构建和权限提升的智能处理,手把手教你掌握游戏中的高级黑客技巧。通过多库联合利用和错误处理优化,提升脚本的效率和成功率。

weixin_42537919的博客 394

系统定义的TypeHandler

setParameter 方法,是使用 typeHandler 通过 PreparedStatement 对象进行设置 SQL 参数的时候使用的具体方法,其中 i 是参数在 SQL 的下标,parameter 是参数,jdbcType 是数据库类型。其中有 3 个 getResult 的方法,它的作用是从 JDBC 结果集中获取数据进行转换,要么使用列名(columnName)要么使用下标(columnIndex)获取数据库的数据,其中最后一个 getResult 方法是存储过程专用的。

unber的博客 234

[运动规划算法]基于飞行走廊的轨迹优化

文章目录简介一、介绍二、原理飞行走廊生成三、项目演示参考 简介 Btraj是一个在线的四旋翼无人机的运动规划框架,主要用于未知环境中的自主导航。基于机载状态估计和环境感知,采用基于快速行进(FM *)的路径搜索方法,从基于构建的欧氏距离场(ESDF)中寻找路径,以实现更好的时间分配。通过对环境进行膨胀生成四旋翼无人机的飞行飞行走廊。使用伯恩斯坦多项式将轨迹表示为分段Bezier曲线,并将整个轨迹生成问题转换成凸问题。通过使用Bezier曲线,可以确保轨迹的安全性和高阶动力学可行性,可以将轨迹完全限制在安全

xiewf的博客 8063

MyBatis配置typeHandler类型转换器 (自定义类型转换器)

MyBatis配置のtypeHandler类型转换器 - 简书 https://www.jianshu.com/p/8e0a2d06892c     初始typeHandler 在JDBC中,需要在PreparedStatement对象中设置那些已经预编译过的SQL语句 参数。 执行SQL后,会通过ResultSet对象获取得到数据库的数据,而这些MyBatis是根据数据的类型通过type...

我是guyue,guyue就是我O(∩_∩)O 3540

Halcon棋盘格畸变矫正

通常我们使用的相机都是带有一定的畸变的,只是畸变的大小不同。对于我们常见的测量项目来说,对测量精度的要求很高,通常从相机镜头上进行优化,但是即使镜头优化或者成本原因,造成图像仍有一定的畸变时,我们就可是使用棋盘格标定板,进行畸变矫正。

m0_51559565的博客 3396

2024高校网络安全管理运维赛题目--复现+题目+wp

官方writeup集思广益比较好的备份。

书山有路勤为径,学海无涯苦作舟 1323

SpringBoot中MyBatis使用自定义TypeHandler

1. 前言2. 自定义TypeHandler的应用场景3. 实现自定义 TypeHandler4. 在 MyBatis 配置中使用 TypeHandler方式一:在mybatis-config.xml中配置方式二:使用注解配置5. 在实体类中应用自定义TypeHandler6. 总结在 Spring Boot 项目中集成 MyBatis 时,我们有时需要处理数据库字段与 Java 对象属性之间的特殊转换,这时可以使用 MyBatis 提供的自定义。

Micro麦可乐的博客 1万+

游戏数据训练世界模型:AI物理规律学习与仿真应用实践

世界模型作为理解现实世界动态的AI工具,通过多模态数据学习物理和空间属性来预测未来状态。其核心原理在于从环境交互中提取物理规律,技术价值体现在能够安全、低成本地训练AI系统应对复杂场景。在应用层面,游戏数据因其结构化环境和内置物理引擎,成为世界模型训练的优质素材。游戏世界中的物体交互、运动轨迹等数据天然包含现实物理规律,特别适合训练物理AI。本文以General Intuition公司获得3.2亿美元融资为切入点,深入探讨游戏数据在世界模型训练中的技术实现路径,涵盖数据提取管道构建、多模态数据融合方法,以及

weixin_29056865的博客 367

mybatis第五话 - mybatis情同手足的插件之TypeHandler和Interceptor

源码分析完了,其实还有很多附加的插件没有分析了,因为这些给开发者实现用的,所以还是先学会用再看源码了。 今天主要两个点: 1. TypeHandler入参出参实现使用 2. Interceptor插件实现使用

生生不息,则源源不断 1098

【华为OD机试真题 2025B卷】737、统计监控器、需要打开多少监控器 | 机试真题+思路参考+代码分析(C++、Java、Py、C语言、JS)

【华为OD机试真题 2025B卷】737、统计监控器、需要打开多少监控器 | 机试真题+思路参考+代码分析(C++、Java、Py、C语言、JS) 华为od机试,华为od机试真题,华为od机试E卷,华为odE卷,华为od机试真题E卷,华为OD,华为OD机试,华为OD机试真题,华为od机考,华为od机试D卷,华为od机试真题D卷,华为od手撕代码,华为od,华为od机试C卷,华为od e卷,华为2025e卷,od机试,2025E卷,华为OD机试E卷,什么是华为od,华为od介绍,全面了解华为od,2025华为

KJ.JK 715

AUTOSAR进阶图解==>AUTOSAR_SWS_BSWGeneral

本文详细解析AUTOSAR基础软件(BSW)模块的通用规范,涵盖其分层架构、配置管理、初始化流程和状态转换机制。AUTOSAR采用清晰的分层设计,包括应用层、服务层、ECU抽象层和微控制器抽象层,各层模块通过标准化接口交互。BSW模块配置采用类型化定义,支持预初始化、初始化和后期构建配置。文档还阐述了模块初始化流程中的依赖管理,以及运行时的状态转换与错误处理机制,为汽车电子控制单元的标准化开发提供规范指导。

一名留德华的,康德的信徒的,专注于汽车电子领域的博客 1127

一文搞懂MyBatis中的TypeHandler

结合示例工程,对Mybatis中的类型处理器TypeHandler的定义,实现方式,生效条件进行了深入分析。

用朴素的话说技术。 3828

Allegro如何设置走线自动删除重复走线操作指导

Allegro如何设置走线是自动删除重复走线操作指导在PCB布线的时候,点到点需要重复走一段线的时候,希望原来的线段自动被删除,Allegro设计的时候支持这个操作如下图,重复走中间的线段的时候,希望下方的走线自动删除具体操作如下This section is describe what the function allegro have ,helpfully could let user know more about allegroAllegro Design and Analysis includes

weixin_54787054的博客 4498

Mybatis之类型转换器TypeHandler的初步了解及具体使用方法

Mybatis之类型转换器TypeHandler的初步了解及具体使用方法

weixin_43448760的博客 7151

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

mybatis typeHandler类型转换器

 typeHandler类型转换器     在JDBC中,需要在PreparedStatement对象中设置那些已经预编译过的SQL语句的参数。执行SQL后,会通过ResultSet对象获取得到数据库的数据,而这些MyBatis是根据数据的类型通过typeHandler来实现的。在typeHandler中,分为jdbcType和javaType,其中jdbcType用于定义数据库类型,而java...

weixin_33834910的博客 171

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

Mybatis中typeHandler类型转换器

一.typeHandler简介 在JDBC中,需要在PreparedStatement对象中设置那些已经编译过的SQL语句的参数.执行sql后,会通过ResultSet对象获取得到数据库的数据,而这些Mybatis是根据数据的类型通过typeHandler来实现的.在typeHandler中,分为jdbcType和javaType,其中jdbcType用于定义数据库类型,而javaType用于定义java类型,那么typeHandler的作用就是承担jdbcType和javaType之间的相互...

红颜若雪的博客 790

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

Mybatis TypeHandler类型转换器

类型处理器Java类型JDBC类型数据库兼容的 BOOLEAN数据库兼容的 NUMERIC 或 BYTE数据库兼容的 NUMERIC 或 SHORT INTEGER数据库兼容的 NUMERIC 或 INTEGER数据库兼容的 NUMERIC 或 LONG INTEGER数据库兼容的 NUMERIC 或 FLOAT数据库兼容的 NUMERIC 或 DOUBLE数据库兼容的 NUMERIC 或 DECIMAL——NCLOB——byte[]数据库兼容的字节流类型byte[]

网络安全学习教程分享 992

Mybatis类型转换器(typeHandler)

1.简介       在JDBC中,需要在PreparedStatement对象中设置那些已经预编译过的SQL语句参数。 执行SQL后,会通过ResultSet对象获取得到数据库的数据,而这些MyBatis是根据数据的类型通过typeHandler来实现的。      在typeHandler中,分...

qq_33865863的博客 1027

Mybatis-TypeHandler类型转换器

在这一讲我们重点介绍了 MyBatis 中 JdbcType 与 Java 类型之间转换的相关实现。首先,介绍了 JdbcType 与 Java 类型之间的常见映射关系,以及两种类型之间转换的基础知识,深入分析了 TypeHandler 接口及其核心实现,了解了两种类型转换的原理;接下来,又讲解了 TypeHandler 的注册和查询机制,明确了 MyBatis 是如何管理和使用众多的 TypeHandler 实现;最后,分析了 MyBatis 中的别名实现。

善守者 1374

oracle typehandler,Mybatis实现自定义的类型转换器TypeHandler

此文其实是java操作Oracle类型XMLType总结二:使用Mybatis附带的一篇小结。Mybatis实现自定义的转换器,十分的简单,其主要步骤分为三步,这里以操作XMLType类型为例。 第一步新建一个转换类,实现TypeHandler接口,接口的泛型指定参数类型,不指定则为Object:public class XmltypeTypeHandler implements TypeHand...

weixin_39702799的博客 388

012,Mybatis TypeHandler类型转换器

TypeHandler类型转换器 1,概述: 我们思考一个问题,我们之前在是使用JDBC的时候,我们从ResultSet获取对应的数据,用到了对应getXXX方法。比如获取一个数据库为int的数据,我们可以使用rs.getInt(),如果我们获取数据库类型为varchar的数据,我们可以使用rs.getString()。 而我们现在使用了Mybatis之后,从数据库里面查询出来了之后,他是如何把数据库的类型和Java类型对应起来的呢?这个地方Mybatis就用到了typeHandler来实现。 2,

V哥教育,java技术博客 295

Mybatis之typeHandler类型转换器

引言:在JDBC中,需要在PreparedStatement对象中设置那些已经预编译过的SQlL语句的参数。执行SQL后,会通过ResultSet对象获取得到数据库的数据,而这些在Mybatis是根据数据的类型通过typeHandler来实现的。 在typeHandler中,分为jdbcType和javatype,其中jdbcType用于定义数据库类型,而javaType用于定义Java类型,那么...

weixin_42572590的博客 872

玩转Mybatis中的类型转换器TypeHandler

1.场景 日常java开发中经常有这种需求,用0或者1这些代码(不局限于数字)来表示某种状态。比如用0表示女性,用1来表示男性。而且写入数据库可能是一个标识,从数据库读取又还原为具体的说明。而且一般情况下为了更好理解或者消除魔法值,通常的处理方案是定义一个枚举: 有些枚举是这样定义的 public enum GenderType{ FEMALE,MALE,UNKNOWN } 那么通常很多人会这么入库(java伪代码) if(GenderType.MALE){ // 写入 1

V539413949的博客 818

mybatis typeHandler自定义类型转换器

有这样一个需求: 有一个布尔型的字段需要保存到数据库中,但是数据库不支持布尔类型,因此采用一位字符(char(1))来存储这个布尔值,javabean中仍然采用boolean类型。 我们采用mybatis作为持久层框架,但是就有一个问题,数据库中使char型,而程序中是boolean型,如何实现数据类型自动转换? 解决办法: mybatis提供了对自定义的类型转换器(typ

jacob_shen的专栏 2803

MyBatis中的TypeHandler类型转换器说明和使用

TypeHandler是类型转换器,在mybatis中用于实现java类型和JDBC类型的相互转换。 java类型->jdbc类型:mybatis使用prepareStatement来进行参数设置的时候,需要通过typeHandler将传入的java参数设置成合适的jdbc类型参数,这个过程实际上是通过调用PrepareStatement不同的set方法实现的; jdbc类型->java类型:在获取结果返回之后,也需要将返回的结果转换成我们需要的java类型,这时候是通过调用ResultSet对

qq_35227352的博客 1332

Mybatis——TypeHandler 类型转换器

Mybatis——TypeHandler类型转换器 jdbcType:定义了数据库中的数据类型。 javaType:定义了java中的数据类型。 TypeHandler:承担了jdbcType和javaType之间的互相转换。 一、TypeHandler 接口源码 /* * TypeHandler接口 * @ BaseTypeHandler<T> * */ public interface TypeHandler<T> { //通过PreparedStatement设置S

wumenghao的博客 232
上一篇: mybatis执行流程源码分析
下一篇: java线程池源码分析
li_a_long
博客等级 码龄9年 1粉丝 15原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值