【发布时间】:2021-06-18 11:03:54
【问题描述】:
我正在尝试将映像保存到 Oracle 数据库(Oracle 数据库 12c 企业版版本 12.1.0.2.0)。每次我使用我的存储库保存它(更新或插入语句)时,我都会收到以下异常:
oracle.jdbc.OracleDatabaseException: ORA-00932: inconsistent datatypes expected - got BLOB
我的实体
@Entity
public class Profile {
@Id
private Long id;
@Column
private String name;
@Lob
@Column
private byte[] image;
//getters and setters
}
我的仓库:
@Repository
public interface ProfileRepository extends JpaRepository<Profile, Long> {
}
最后但并非最不重要的是我的服务方法:
@Transactional
public void saveProfile(Profile profile) {
profileRepository.save(profile);
}
我的 ddl 脚本:
create table "profile"
(
image BLOB not null,
name varchar2(30) not null,
ID NUMBER no null primary key
);
我尝试将图像字段类型更改为java.sql.Blob,但它也不起作用。有谁知道如何解决这个问题?
【问题讨论】:
-
您是如何尝试使用
Blob的,您遇到了什么错误?您必须使用@Lob对其进行注释。你也可以分享堆栈跟踪吗?
标签: oracle spring-boot hibernate jpa spring-data-jpa