![](https://img-blog.csdnimg.cn/20200619105912684.jpg?x-oss-process=image/resize,m_fixed,h_224,w_224)
mybatis
MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名为MyBatis 。2013年11月迁移到Github。
iBATIS一词来源于“internet”和“abatis”的组合
wuyuanshun
这个作者很懒,什么都没留下…
展开
-
springboot连接两个多个数据库/数据源(多个)
和之前的项目的主要区别就是 mapper包多了一个,mapper的xml包也多了一个,不同的数据库mapper放到不同的包内就可以了。在使用多数据源时,有可能会遇到事物失败的问题。我单独总结了一个文章。需要的话可以阅读一下。1.注意:@MapperScan 的basePackages就是你包的路径 ,可能有人不清楚项目的结构,我在下面放了一张类结构图,能更清晰和方便理解。sqlSessionFactoryRef 可以随便起名 但是着两个类。1.启动类需要不用加mybatis的@MapperScan注解。原创 2019-12-03 20:30:38 · 47204 阅读 · 8 评论 -
Mybatis 批量操作问题 Too many keys are generated. There are only 1 target objects
错误代码:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.executor.ExecutorException: Too many keys are g原创 2022-04-19 17:39:08 · 5206 阅读 · 1 评论 -
IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType.xxxx
Error resolving JdbcType. Cause: java.lang.IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType.xxxx报错因为mapper的xml文件写的有问题,我的问题是出在resultMap中jdbcType值写错了;应该写全大写BOOLEAN,由于不小心粘贴实际写成了Boolean,导致报错。 报错提示会提出出是什么类型出错即可准确定位。如 No enum constan原创 2021-04-01 18:52:50 · 1408 阅读 · 0 评论 -
Spring Boot项目多数据源class path resource [mybatis/] cannot be resolved to URL because it does not exist
Spring Boot项目多数据源启动失败class path resource [mybatis/] cannot be resolved to URL because it does not existSpring Boot项目多数据可以参考之前的项目(springboot连接两个数据库(多个)) ,如果过数据源配置失败 显示以上报错则可能是如下位置的配置报错,按规律修改所有数据库配置了类的相应配置即可。 @Bean(name = "oneSqlSessionFactory") pub原创 2021-02-04 13:29:28 · 2355 阅读 · 2 评论 -
It‘s likely that neither a Result Type nor a Result Map was specified.
It's likely that neither a Result Type nor a Result Map was specified.很可能既没有指定结果类型,也没有指定结果映射。在编写mybatis的xml文件时 如编写查询语句一定要加resultType 或resultMap 。如下:加parameterType<select id="getSidStarDelayed" resultType="com.wys.pojo.NameBean" parameterType="com.原创 2021-01-04 21:25:45 · 10377 阅读 · 1 评论 -
Springboot多数据源问题之 Could not resolve type alias ‘Blog‘.
Springboot多数据源之 Could not resolve type alias ‘Blog’.由于配置了多数据源,mapper的xml文件放错了包。如下图只需要把xml文件放到对应的包里就行。多数据源的详解请看:链接: springboot连接两个数据库(多个)...原创 2020-12-08 18:26:44 · 907 阅读 · 0 评论 -
Error querying database syntax error at or near “$1“
Error querying database syntax error at or near “$4”查询数据库时出错 第4个参数附件语法错误↵### Error querying database. Cause: org.postgresql.util.PSQLException: ERROR: syntax error at or near "$4"↵ 位置:665↵### The error may exist in file [E:\demo\service\target\classes原创 2020-10-22 15:32:50 · 3262 阅读 · 0 评论 -
Mybatis boolean和bit不对应 column “xxx“ is of type bit but expression is of type boolean
column “xxx” is of type bit but expression is of type boolean“xxx”列的类型为bit,但expression的类型为booleanpostgre原创 2020-09-03 18:05:20 · 5799 阅读 · 0 评论 -
Could not set parameters for mapping: ParameterMapping(已解决)
当问们遇到Could not set parameters for mapping: ParameterMapping错误时,多数为我们的mapper映射写的有问题,检查我们的sql语句。如:中英文符号、大于小于号等 ,特别是小于号。只要细心,都不是问题。< 小于号 > 大于号...原创 2020-03-14 14:02:56 · 24168 阅读 · 0 评论 -
mybatis查询float类型异常
mybatis查询float类型异常-mybatis查询float类型结果为空1.问题例如我们有一个包含Float类型属性的实体,在通过接口接收对象参数(SpringMVC阶段)没有问题。但是在执行完查询语句后,没有结果。2.原因分析有可能是Float类型的精准度丢失,导致数据不准确,可以把Float类型换成Double类型,然后再执行查询或其他数据库操作就可以解决问题了。...原创 2020-05-25 16:42:41 · 1970 阅读 · 0 评论 -
java Column count doesnt match value count at row 1
Column count doesn’t match value count at row 1列计数与第1行的值计数不匹配应为sql语句对应的?也就是参数,和mapper接口的不一致。接口 List<Column > getColumn (@Param("dateStart") Date dateStart, @Param("dateEnd") Date dateEnd, @Param("min") String min);sqlselect * from temp wh原创 2020-05-25 16:15:44 · 578 阅读 · 0 评论 -
mybatis异常java.lang.IllegalArgumentException: invalid comparison: java.util.Date and java.lang.String
在mybatis中不能用传入的日期参数与空字符串进行比较,只保留非空判断即可<if test="createTime != null and createTime != ''">...</if>改为:<if test="createTime != null">...</if>...原创 2019-11-16 13:14:47 · 223 阅读 · 0 评论