我已经在这里和那里一直在遵循一些解决方案,但是仍然无法使其正常工作。
我已经有了Oracle数据库和这个实体:
@Entity(name = "NGRAM")
public class Ngram
{
@Id
@JsonProperty("ngram")
private String ngram;
@JsonProperty("frequency")
@Column(name = "frequency")
private int frequency;
@JsonProperty("occurrences")
@Column(name = "occurrences")
private int occurrences;
我正在尝试添加此@SQLInsert查询:
@SQLInsert(sql="INSERT INTO NGRAM
(ngram, frequency, occurrences)
VALUES (?, ?, ?)
ON DUPLICATE KEY UPDATE
frequency = frequency + 1,
occurrences = occurrences + VALUES(occurences);")
但是我通过几种不同的解决方案得到了这个错误:
2019-01-28 16:35:22 DEBUG org.hibernate.SQL - INSERT INTO NGRAM(ngram, frequency, occurrences) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE frequency = frequency + 1, occurrences = occurrences + VALUES(occurences);
2019-01-28 16:35:22 TRACE o.h.type.descriptor.sql.BasicBinder - binding parameter [1] as [INTEGER] - [1]
2019-01-28 16:35:22 TRACE o.h.type.descriptor.sql.BasicBinder - binding parameter [2] as [INTEGER] - [2]
2019-01-28 16:35:22 TRACE o.h.type.descriptor.sql.BasicBinder - binding parameter [3] as [VARCHAR] - [since constraints]
2019-01-28 16:35:22 WARN o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: 933, SQLState: 42000
2019-01-28 16:35:22 ERROR o.h.e.jdbc.spi.SqlExceptionHelper - ORA-00933: SQL command not properly ended
这是我的查询错误吗?
我已经读过from here,在同一事务中两次更新/插入同一行可能会导致问题,我正在使用Repo.saveAll来稍微提高速度,但据我所知应该是唯一的,因为我是从具有Map(String,Integer)的地图中获取它们的。