hibernate映射文件中的列名周围的[]是什么意思吗?
实施例
<property name="tableCol" column="[TABLE_col]" not-null="false" type="long" unique="false" optimistic-lock="true" lazy="false" generated="never" />
VS
<property name="tableCol" column="TABLE_col" not-null="false" type="long" unique="false" optimistic-lock="true" lazy="false" generated="never" />
答案 0 :(得分:0)
如果要将数据库保留关键字用作列名,则使用列名称周围的[]
。
示例:
如果您有一个名为DESC
的列是数据库保留关键字,如果您尝试使用它将导致JDBCException
:
<property name="tableCol" type="string" >
<column name="DESC" type="long" not-null="false" />
</property>
您必须使用:
<property name="tableCol" type="string" >
<column name="[DESC]" type="long" not-null="false" />
</property>