lmtoo opened SPR-17097 and commented
I have a table, defined as follows:
create table im.t_process_instance_attributescreate table im.t_process_instance_attributes( ownerId int default '0' not null, `key` varchar(50) default '' not null, value varchar(200) null, primary key (ownerId, `key`));
While SimpleJdbcInsert
generated insert sql is:
INSERT INTO t_process_instance_attributes (ownerId, key, value) VALUES(?, ?, ?)
Key column doesn't have escape symbol, and BadSqlGrammarException
is thrown.
No further details from SPR-17097
Comment From: leolee192
Duplicate of #13874
Comment From: sbrannen
@ledoyen, thanks for pointing that out.
Closing this issue as a duplicate of #13874.
Comment From: ledoyen
@sbrannen
I think you wanted to mention @leolee192 :wink:
Comment From: sbrannen
Indeed. Sorry about the noise. I'll just blame that on auto-correct.
Comment From: sadafzohra19
One workaround is to enclose the column name in quotes or brackets, depending on the database vendor. This will tell the database to treat the column name as a literal string and not as a keyword. For example, in MySQL, you can use backticks to enclose the column name, like this:
SimpleJdbcInsert insert = new SimpleJdbcInsert(jdbcTemplate); insert.withTableName("my_table").usingColumns("
select", "other_column");