JPA @Column does not work for column name with special character

Viewed 689

I have a column with name like ac-bnm_kj.

I have defined the attribute in the entity class as:

@Column("ac-bnm_kj")
String acbnm;

But this config is giving me the following error:

ORA-01747: invalid user.table.column, table.column, or column specification

because the query is generating with name ac-bnm_kj which is invalid. How can I wrap double quotes around this column name when the query is being generated like ac-bnm_kj?

1 Answers

You should use backticks:

@Column("`ac-bnm_kj`")
String acbnm;

or JPA style quoting

@Column("\"ac-bnm_kj\"")
String acbnm;
Related