開心每一天1111
2019-07-11 10:17:59
用JPA創(chuàng)建具有保留字名的字段@Column(name="open")使用sqlserver方言和Hibernate。[SchemaUpdate] Unsuccessful: create table auth_session (id numeric(19,0) identity not null, active tinyint null,
creation_date datetime not null, last_modified datetime not null, maxidle int null, maxlive int null, open tinyint null,
sessionid varchar(255) not null, user_id numeric(19,0) not null, primary key (id), unique (sessionid))[SchemaUpdate]
Incorrect syntax near the keyword 'open'.我希望Hibernate在創(chuàng)建表時使用引用的標(biāo)識符。對如何處理這件事有什么想法.。除了改名外?
3 回答

一只甜甜圈
TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超5個贊
@Column(name="`open`")
5.4.SQL引號標(biāo)識符
您可以強(qiáng)制Hibernate引用生成的SQL中的標(biāo)識符,方法是將表或列名封裝在映射文檔的Backticks中。Hibernate將對SQL方言使用正確的引號樣式。這通常是雙引號,但SQLServer使用括號,MySQL使用Backticks。 <class name="LineItem" table="`Line Item`"> <id name="id" column="`Item Id`"/><generator class="assigned"/></id> <property name="itemNumber" column="`Item #`"/> ...</class>
@Column(name="\"open\"")
參考文獻(xiàn)
Hibernate參考指南 JPA2.0規(guī)范 2.13數(shù)據(jù)庫對象的命名
相關(guān)問題

守著星空守著你
TA貢獻(xiàn)1799條經(jīng)驗(yàn) 獲得超8個贊
@Column(name="[order]")private int order;
添加回答
舉報(bào)
0/150
提交
取消