如何通过sql脚本将blob数据插入到Spring的嵌入式HSQLDB中?

如何通过sql脚本将blob数据插入到Spring的嵌入式HSQLDB中?,spring,spring-data,hsqldb,spring-data-jpa,sql-scripts,Spring,Spring Data,Hsqldb,Spring Data Jpa,Sql Scripts,这是我创建数据库的sql脚本: create table product (id integer identity primary key, name varchar(50) not null, price decimal(10,2) not null, image blob(1024), category_id integer); INSERT INTO product VALUES (1, 'ProductName', 699.95, load_file('full_path'), 1)

这是我创建数据库的sql脚本:

create table product 
(id integer identity primary key,
name varchar(50) not null,
price decimal(10,2) not null,
image blob(1024),
category_id integer);
INSERT INTO product VALUES (1, 'ProductName', 699.95, load_file('full_path'), 1);
这是我的sql脚本,它将数据插入数据库:

create table product 
(id integer identity primary key,
name varchar(50) not null,
price decimal(10,2) not null,
image blob(1024),
category_id integer);
INSERT INTO product VALUES (1, 'ProductName', 699.95, load_file('full_path'), 1);

根据HSQLDB,完整路径默认为数据库位置的相对路径。那么,对于位于/resources/img/下的图像文件,我必须给出什么作为文件路径呢?(Spring通过使用以下URL创建DB:jdbc:hsqldb:mem:testdb)

您可以派生类路径资源的绝对路径,如下所示

new ClassPathResource("img/abc.gif").getFile().getAbsolutePath()

请参阅param的说明


它允许您使用不同的文件路径变体。

在使用HSQLDB配置测试时,我遇到了相同的问题。似乎HSQLDB只支持
加载文件(“完整路径”)
,它只接受绝对文件路径

或者,为了获得相同的结果,在H2 DB中使用嵌入式DB配置

在H2配置中,相同的查询如下所示

INSERT INTO product VALUES (1, 'ProductName', 699.95, FILE_READ('classpath:filename.ext');
“来自sql脚本”。不是来自java。