Incorrect syntax near the keyword 'key'

Viewed 980

I am trying to persist a new object into the database, but i am getting this error:

SQL Error: 156, SQLState: S0001

Incorrect syntax near the keyword 'key'.

What I am doing

Bucket bucket = new Bucket();
bucket.setKey(key);
bucket.setValue(value);


entityManager.persist(bucket);

I believe this error is due to the keyword 'key' being used in sql statements causing this. Is there a native query that I can use to insert rows into my table?

My table has these three columns, with Id being auto-generated.

Bucket:

@Entity
@Getter
@Setter
@ToString
public class Bucket {

    @Id @GeneratedValue(strategy= GenerationType.IDENTITY)
    private long id; //auto allocation of PK
    private String key;
    private String value;
} 

1 Answers

Thank you Martin Smith for the help. Just one simple change and the issue was resolved.

Bucket:

@Entity
@Getter
@Setter
@ToString
public class Bucket {

    @Id @GeneratedValue(strategy= GenerationType.IDENTITY)
    private long id; //auto allocation of PK
    @Column(name = "\"key\"")
    private String key;
    @Column(name = "\"value\"")
    private String value;
} 

Related