-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
SQLite数据库保存数据报错 #5709
Comments
这看着是驱动不支持呀 |
@nieqiurong 所以这是 mybatis-plus 框架的问题还是 sqlite-jdbc 的问题啊 |
不是已经给出来SQLFeatureNotSupportedException了么,驱动不实现这个也没办法,只能规避. |
@nieqiurong 我觉得不是这样的,sqlite-jdbc没有实现insert方法我觉得离谱,另外我不通过mybatis-plus而是直接使用该驱动直接执行SQL是成功的,步骤如下: Connection connection;
try {
Class.forName("org.sqlite.JDBC");
connection = DriverManager.getConnection("jdbc:sqlite::resource:db/database.db");
Statement statement = connection.createStatement();
statement.execute("create table person(id, name)");
statement.execute("insert into person(id, name) values (1, 'test')");
statement.close();
connection.close();
} catch (Exception e) {
System.err.println(e.getClass().getName() + ": " + e.getMessage());
System.exit(0);
}
System.out.println("insert successful."); |
要返回自增主键 |
jdbc batch |
将版本回退到3.42.0.1可以暂时解决,sqlite更改了获取id的方法,因为原来的方法不能正确返回id。现在是需要在sql语句后面添加 RETURNING 子句,然后才会返回id结果,这不是标准sql语法。mybatis-plus还未支持这种写法。 |
当前使用版本(必填,否则不予处理)
3.5.3.1,3.5.3.2均必现,猜测其他早期版本也可能是这样,已经验证并非是sqlite-jdbc的问题
该问题是如何引起的?(确定最新版也有问题再提!!!)
调用mapper的insert方法或者service的saveBatch方法保存数据时均报错,但是可以插入一条数据(saveBatch方法传数组能插入第一条数据后面的插入失败)
重现步骤(如果有就写完整)
pom.xml
配置文件:
报错信息
The text was updated successfully, but these errors were encountered: