Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 科特林+;弹簧靴&x2B;SQLite保存对象而不是语句。executeUpdate(“…”)_Spring_Spring Boot_Sqlite_Kotlin - Fatal编程技术网

Spring 科特林+;弹簧靴&x2B;SQLite保存对象而不是语句。executeUpdate(“…”)

Spring 科特林+;弹簧靴&x2B;SQLite保存对象而不是语句。executeUpdate(“…”),spring,spring-boot,sqlite,kotlin,Spring,Spring Boot,Sqlite,Kotlin,我正在从事一个使用Kotlin、Spring Boot和SQLite的项目,我使用的依赖项是: <dependency> <groupId>org.xerial</groupId> <artifactId>sqlite-jdbc</artifactId> <version>3.16.1</version> </dependency> 这很好,但是:由于表是自动创建的,因此不可

我正在从事一个使用Kotlin、Spring Boot和SQLite的项目,我使用的依赖项是:

<dependency>
    <groupId>org.xerial</groupId>
    <artifactId>sqlite-jdbc</artifactId>
    <version>3.16.1</version>
</dependency>
这很好,但是:由于表是自动创建的,因此不可能出现如下情况:

var person= Person(0,"Bob")
var connection: Connection = DriverManager.getConnection("jdbc:sqlite:test/sqlitesample.db")
connection.save(person)//this is made up code, this method doesn't exist.
因此,问题是:


您能否要求DB管理器保存一个数据对象的实例,因为它使用该对象来创建表,而不是使用查询?

看看Spring Boot data JPA,它正是您所需要的。它提供了
crudepository
界面,可用于创建/读取/更新/删除实体

关于这个问题有很多资源。例如,指南是用Java编写的,但没有多大区别

var person= Person(0,"Bob")
var connection: Connection = DriverManager.getConnection("jdbc:sqlite:test/sqlitesample.db")
connection.save(person)//this is made up code, this method doesn't exist.