hibernate createSQLQuery StringIndexOutOfBoundsException: String index out of range: 0
有一个sql用union拼接的如下:
select id,(**还有很多字段**),'' as NewName from tb1
union
select id,(**还有很多字段**),name as NewName from tb2
union
select id,(**还有很多字段**),name as NewName from tb3
tb1表中不存在这个字段所以用'' as NewName
tb2,tb3中有这了个字段是varchar的
查询以一直报错:StringIndexOutOfBoundsException: String index out of range: 0
1.但是每个select单独查询完全没问题 ,开始以为是union的问题,
2.去掉NewName 这个字段后也没问题,.以为是sql太长了,
3.解决:最后网上查是因为:处理方法 数据表字段为char导致,修改为VARCHAR. 建表时不要使用char类型,为null就会报以上错误
原因是tb1中:'' as NewName以为是char而下面有数据的是varchar所以union的时候类型不一样就会报错。
最后把: '' as NewName 改成 null as NewName
改完成SQL如下,搞定:
select id,(**还有很多字段**),null as NewName from tb1
union
select id,(**还有很多字段**),name as NewName from tb2
union
select id,(**还有很多字段**),name as NewName from tb3
和上面相反的问题
hibernate createSQLQuery报错: MappingException: No Dialect mapping for JDBC type: 0
有SQL,只有一个select:
select id,(**还有很多字段**),null as isVisit from Table 报错MappingException: No Dialect mapping for JDBC type: 0 (isVist数据库中不存在这个字段)把: null as isVisit 改成 null as isVisit 搞定:
select id,(**还有很多字段**),'' as isVisit from Table
hibernate createSQLQuery StringIndexOutOfBoundsException: String index out of range: 0的更多相关文章
- java.lang.StringIndexOutOfBoundsException: String index out of range: 0
hibernet 报错 java.lang.StringIndexOutOfBoundsException: String index out of range: 0 处理方法 数据表字段为char ...
- Spring Boot 启动报错 Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 37
使用命令 java -jar springBoot.jar 启动项目,结果报错如下: Exception at java.lang.String.substring(String.java:) at ...
- tk.mybatis 报错:tk.mybatis.mapper.MapperException: tk.mybatis.mapper.MapperException: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'apiLogMapper ...
- IndexError:string index out of range
IndexError:string index out of range 出现在下标越界的情况,如 item[1],可能为空的时候下标就会越界
- mac安装MySQLdb:IndexError: string index out of range
使用mac安装MySQLdb的时候出现string index out of range 大概的错误是这样的: 然后尝试手动安装,我下载了包后,依然出现这个错误. 于是百度了下: https://ww ...
- java.sql.SQLException:Column Index out of range,0<1
1.错误描述 java.sql.SQLException:Column Index out of range,0<1 2.错误原因 try { Class.forName("com.m ...
- MacOS 安装MysqlDB 问题解决方案( 解决 IndexError: string index out of range)
pip install MySQL-python时报错如下: Command "python setup.py egg_info" failed with error code 1 ...
- Mac安装Mysql-python遇到的坑,被这俩报错反复摩擦:'my_config.h' file not found 和 IndexError: string index out of range
最后Stackoverflow上面的大神解决了问题: Link brew install mysql brew unlink mysql brew install mysql-connector-c ...
- java.sql.SQLException: Parameter index out of range (0 < 1 ).
向SQL中传入数据是从1开始的!!! 从ResultSet中取数据也是从1开始的!
随机推荐
- xcode 左边导航栏中,类文件后面的标记“A”,"M","?"……等符号的含义???
"M" = Locally modified "U" = Updated in repository "A" = Loc ...
- 剑指offer 20:顺时针打印矩阵
题目描述 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下4 X 4矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 则依次打印出数 ...
- 3.智能快递柜(通信篇-HTTP)
1.智能快递柜(开篇) 2.智能快递柜(终端篇) 3.智能快递柜(通信篇-HTTP) 4.智能快递柜(通信篇-SOCKET) 5.智能快递柜(通信篇-Server程序) 6.智能快递柜(平台篇) 7. ...
- laravel Error 笔记
一.有关CSRF验证 1.网址访问POST请求,如 127.0.0.1:81/delUser?id=1 网页请求是默认是GET请求方式,看返回的数据信息就知道,数据是以GET方式发送的,所以若路由中 ...
- [b0028] python 归纳 (十三)_队列Queue在多线程中使用
# -*- coding: UTF-8 -*- """ 多线程同时读队列 总结: 1. 会阻塞 if self._jobq.qsize() > 0 进入逻辑,此时被 ...
- .net core 发布IIS 出现Http 500错误
首先再webconfig中设置stdoutLogEnabled="true",然后运行之后,到logs中查看登陆错误日志. 根据不同的错误进行解决: 我的错误是发布文件夹中缺少Dw ...
- TensorFlow Federated:基于分散式数据的机器学习
https://www.tensorflow.org/federated/ TensorFlow Federated (TFF) 是一个开源框架,用于对分散式数据进行机器学习和其他计算.我们开发 TF ...
- 接口是用get还是post,如何选择?
为了保证信息安全性,注册.登录等操作通常都会使用POST请求,GET请求一般用来获取信息 GET与POST的区别可以参考下方链接 https://www.cnblogs.com/hyddd/archi ...
- python27期python连接数据库:
import pymysql创建connectinon对象:con = pymysql.connect(host = "localhost",user = "root&q ...
- CloudCompare中对点云进行降采样和剪裁
降采样: Edit=>Subsample 出现一个弹窗,可以选择3种降采样的方式:Random, Space, Octree. 下面用一个例子来说明3种方式.例子是一个5.88M个点的点云文件( ...