I am overriding CQL statement like this:
@Query("INSERT INTO message (content,email,magic_number,title) VALUES (?, ?, ?, ?);")
Message save(Message message);
but Spring throws Invalid amount of bind variables.
What is wrong here?
EDIT:
I am adding message class:
@Table(value = "message")
@Data
@NoArgsConstructor(force = true)
@AllArgsConstructor
public class Message {
@Column("email")
private String email;
@Column("title")
private String title;
@Column("content")
private String content;
@PrimaryKey
@Column("magic_number")
private int magicNumber;
}
and also json whitch is send to the api:
{
"email": "name@example.com",
"title": "title",
"content": "text123",
"magic_number": 101
}
Spring is expecting 4 bind variables which aligns with the 4 bind markers (?) you have specified in the query.
To make it work you'd have to have add the 4 input parameters to the save() method.
If you extend CassandraRepository the save method is already implemented for you. Is there a reason you're trying to override it?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.