使用JPA创建具有保留字名称的字段 [英] Creating field with reserved word name with JPA

查看:97
本文介绍了使用JPA创建具有保留字名称的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  @Column(name =open)

使用带有hibernate的sqlserver方言。
$ b $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $' activeint 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,主键(id), unique(sessionid))
[SchemaUpdate]关键字'open'附近的语法不正确。

我希望hibernate在创建表时使用带引号的标识符。



关于如何处理这个问题的任何想法...除了重命名字段之外?

解决方案

同样的问题,但是有一个名为 Transaction 的表名。如果你设定了

pre $ hibernate.globally_quoted_identifiers = true

然后将引用所有数据库标识符。



在这里找到我的答案
表名hibernate中的特殊字符给出错误



在这里找到所有可用的设置
https://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/appendices/Configurations.html



找不到更好的文档这虽然。


@Column(name="open")

Using sqlserver dialect with 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'.

I would have expected hibernate to use quoted identifier when creating the table.

Any ideas on how to handle this... other than renaming the field?

解决方案

Had the same problem, but with a tablename called Transaction. If you set

hibernate.globally_quoted_identifiers=true

Then all database identifiers will be quoted.

Found my answer here Special character in table name hibernate giving error

And found all available settings here https://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/appendices/Configurations.html

Could not find better docs for this though.

这篇关于使用JPA创建具有保留字名称的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆