I've been already following a couple of solutions here and there but still not managing to make it work.
I've got and Oracle database and this Entity:
@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;
And I was trying to add this @SQLInsert query:
@SQLInsert(sql="INSERT INTO NGRAM
(ngram, frequency, occurrences)
VALUES (?, ?, ?)
ON DUPLICATE KEY UPDATE
frequency = frequency + 1,
occurrences = occurrences + VALUES(occurences);")
But I got this error using a few different solutions:
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
It's my Query wrong?
I've read from here that updating/inserting same row twice in the same transactio could lead to problems and I'm using Repo.saveAll to improve speed a bit, but as far as I can tell the keys should be unique since I'm getting them from a map having a Map(String, Integer).
INSERT INTO .... VALUES (...) ON DUPLICATE KEY UPDATE ...syntax? it would seem not: stackoverflow.com/questions/15161578/…