Issue
SQLGrammarException: could not execute statement while saving the data
I am getting SQLGrammarException: could not execute statement while saving the data.
If I am executing the same in data view not getting any error.
@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
@Table(name = "area")
@TypeDef(
name = "json",
typeClass = JsonType.class
)
public class Student implements Serializable {
@Id
@Column(name = "id")
private String id;
@Column(name = "name", nullable = false)
private String name;
@Column(name = "subject", columnDefinition = "json")
@Type(type = "json")
private List<Map<String, String>> relation;
@Column(name = "roll")
private String roll;
@Column(name = "class")
private String class;
}
In Service Impl :
myRepo.saveStudent(id, name, roll, class);
All the variable value are avilabel
My Repo :
@Modifying
@Transactional
@Query(value = "insert into student (id, name, roll, class) values (:id, :name, :roll, :class", nativeQuery = true)
void saveStudent(String id, String name, String roll, String class);
Can anybody help me what sql grammer is wrong here,
Solution
You are missing the closing ')' after your values
Answered By - johnnyutts
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)