Spring 科特林+;弹簧靴&x2B;SQLite保存对象而不是语句。executeUpdate(“…”)
我正在从事一个使用Kotlin、Spring Boot和SQLite的项目,我使用的依赖项是: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> 这很好,但是:由于表是自动创建的,因此不可
<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.