Mybatis
问题1:数据怎么迁移?
解决:用官方提供的迁移工具(安装数据库会自动安装)
问题2: 错误: 关系 “dual” 不存在
解决:select 1 from dual 改成: spring.datasource.druid.validationQuery=SELECT 1
问题3:反引号报错:table
解决:改成双引号:“table”
问题4:表存在,字段也存在,却提示字段不存在
解决:sys_开头的表,多数是kb数据库系统表,业务表有同名的,需要在业务sql表面前加上模式名 schema_name.sys_xxx
问题5:没有find_in_set函数
解决:自定义函数:
create or replace function FIND_IN_SET(text, text)
returns bigint
as
$$
select coalesce(min(sn), 0)
from unnest(string_to_array($2, ',')) with ordinality t(val, sn)
where val = $1
$$ language sql;
自定义find_in_set后,提示:错误: WHERE 的参数必需是类型boolean, 而不是类型bigint
因为find_in_set返回值是0到n,大于0表示参数2里面存在参数1,所以根据原sql的需求做如下改动:
-- 原sql:
select * from table t where find_in_set('1', t.a);
-- 改为:
select * from table t where find_in_set('1', t.a) > 0;
问题6:update set xxx = ‘’ 时,提示 空值违反了非空约束
解决:修改kingbase安装目录下的文件:/data/kingbase.conf ora_input_emptystr_isnull = on 改为 off
问题7:kingbase没有uuid()
解决:SYS_GUID_NAME()替代:select SYS_GUID_NAME() from dual;
问题8:用kingbase自带的数据库管理工具,把数据从测试库导入生产库后,表的owner默认为system
解决:
select schemaname,relname from sys_stat_user_tables WHERE schemaname='govo_feedback'; -- 查所有表名
-- 修改owner
ALTER TABLE "govo_feedback"."question" OWNER TO "govo_feedback";
GRANT ALL ON TABLE "govo_feedback"."question" TO "govo_feedback";
问题9:提示TINYINT无法转到boolean
解决:表字段类型从tinyint改成boolean.(或者在用kts迁移工具迁移时,映射tinyint到boolean)
JPA
问题9:org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set
解决:添加配置:
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.Kingbase8Dialect
问题10:spring.jpa.database=KINGBASE 不存在
解决:换成spring.jpa.database=POSTGRESQL
问题11:java.lang.IllegalStateException: dbType not support : null, url null
解决:WallFilter报的错:
java.lang.IllegalStateException: dbType not support : null, url null
at com.alibaba.druid.wall.WallFilter.init(WallFilter.java:167)
at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:839)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1376)
spring.datasource.druid.filters=stat,wall,slf4j
去掉wall,改成:spring.datasource.druid.filters=stat,slf4j