首页 文章

ORA-00932:不一致的数据类型:expected - 得到了clob hibernate / springboot

提问于
浏览
0

使用带有oracle的hibernate来提取存储为base64 LOB的头像图像的记分板数据 . 我做了一些研究,似乎所有其他类似的帖子都是人们试图通过不同或将其放在where子句中与CLOB数据进行比较 . 我也读过oracle不支持临时表(视图)中的CLOB,如果是这种情况,如何从数据库中获取数据 . fyi代码在内存DB的H2中工作 .

查询抛出错误:

select distinct score.userId as userId, sum(score.totalScore) as totalScore, 
    sum(score.timeTaken) as timeTaken, user.image as image
from Score score, User user
where score.userId = user.userId
group by score.userId order by totalScore desc, timeTaken asc

entitities:

用户:

@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "id_Sequence2")
@SequenceGenerator(name = "id_Sequence2", sequenceName = "ID_SEQ2")
@Column(name = "id", updatable = false, nullable = false)
int id;
int userId;
@Lob
String image;
Date createdDate;
Date lastLoggedIn;

得分了:

@Id
@Column(name = "quizID", updatable = false, nullable = false)
int quizId;
@Id
@Column(name = "userID", updatable = false, nullable = false)
int userId;
double totalScore;
@OneToMany(targetEntity=UserQuizRecord.class, fetch=FetchType.EAGER, cascade = { CascadeType.ALL })
List<UserQuizRecord> userQuizRecords;
int timeTaken;
int correctAns;
Date takenDate;

2 回答

  • 0

    检查此链接 .

    https://forum.hibernate.org/viewtopic.php?f=1&t=998284

    因此, DISTINCT 不能与 CLOB 数据类型一起使用,即 image . 请检查这是否解决了您的问题 .

  • 0

    我没有解决确切的问题,但我使用的解决方法(这是不理想但工作)是我得到的一切除了1查询中的图像数据然后有另一个查询图像数据并将图像连接到结束之后观看 . 我只是要查询前100名的结果,所以这不是明智的资源 .

相关问题