5

I have a MySQL DB table which I cannot modify but have to insert values into. It has a column called key which I need to insert into.

Now, my .hbm.xml file has:

    <property name="key"
          type="string"
          column="key" />

The insert query generated hence fails. On adding [key], the generated SQL now contained key but this also failed. On checking in MYSql Workbench, I found that key can work.

However, if I change this in the file mentioned above, it reverts to the "key" as when using [key]. Can someone guide me as to how I can add key and bring about the required insert?

4

1 回答 1

6

There is a hibernate configuration option for this. It needs Hibernate 3.5 which I'm not sure if you're using based on your use of hbm files.

In your hibernate config set

hibernate.globally_quoted_identifiers=true

List of environment config is here

于 2013-06-20T03:07:22.057 回答