when I created a column like name
or password
and so on in PostgreSQL 13. The PostgreSQL may seem it as a reserved key word. so the MyBatis SQL would like this:
INSERT INTO apple_server_notification_record (created_time, updated_time, notification_type, auto_renew_product_id, auto_renew_status, auto_renew_status_change_date, auto_renew_status_change_date_ms, auto_renew_status_change_date_pst, environment, `password`, bid, bvrs) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
it will add `` automaticlly in the SQL. But when execute the sql in PostgreSQL 13. show this error:
org.springframework.jdbc.BadSqlGrammarException:
### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: syntax error at or near "`"
Position: 249
### The error may exist in class path resource [mybatis/mapper/dolphin/AppleServerNotificationRecordMapper.xml]
### The error may involve com.dolphin.soa.post.dao.AppleServerNotificationRecordMapper.insertSelective-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO apple_server_notification_record (created_time, updated_time, notification_type, auto_renew_product_id, auto_renew_status, auto_renew_status_change_date, auto_renew_status_change_date_ms, auto_renew_status_change_date_pst, environment, `password`, bid, bvrs) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
### Cause: org.postgresql.util.PSQLException: ERROR: syntax error at or near "`"
Position: 249
; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: syntax error at or near "`"
Position: 249
I could solved it by change the columns password
to apple_auth_password
, I known it will fix the problem. But In my code, I must tranform the mapping explicit in receive request from apple. My entity define like this:
private String password;
any good suggestion to solve the problem? what would you do when encount this problem?