[英]org.hibernate.exception.SQLGrammarException: could not prepare statement — Spring ROO
I'm Building and web App using the Spring Roo Tool. 我正在使用Spring Roo工具构建Web应用程序。 and while creating my classes via the roo shell console, I've used several times the option
-permitReservedWords
to create some classes (eg Role, Group and User). 在通过roo Shell控制台创建类时,我多次使用
-permitReservedWords
选项来创建一些类(例如Role,Group和User)。
After generating the CRUD Views, I get this exception : 生成CRUD视图后,出现以下异常:
"org.hibernate.exception.SQLGrammarException: could not prepare statement"
“ org.hibernate.exception.SQLGrammarException:无法准备语句”
Then I realized that the problem occurs only for entities with reserved Names, so How can I force these entities name, if it's not possible how can I edit the names, because the refactor option in eclipse doesn't solve the problem, especial with a lot of AspectJ Files in the projects ... 然后我意识到问题仅发生在具有保留名称的实体上,因此如何强制这些实体的名称(如果不可能的话)如何编辑名称,因为eclipse中的refactor选项不能解决问题,特别是带有项目中有很多AspectJ文件...
Note the JPA default table name is the name of the class (minus the package) with the first letter capitalized, this is why you need -permitReservedWords
. 请注意,JPA默认表名是首字母大写的类名(减去包),这就是为什么需要
-permitReservedWords
。 Your entities User , Role , etc by default will be stored in User , Role , etc tables that are reserved words in almost all databases. 默认情况下,您的实体User , Role等将存储在User , Role等表中,这些表在几乎所有数据库中都是保留字。
To change the default behaviour, use the annotation "@Table(name="app_user")" (javax.persistence.Table) to specify/customize the database table name that stores the data of given Entity. 要更改默认行为,请使用批注“ @Table(name =“ app_user”)”(javax.persistence.Table)指定/自定义存储给定实体数据的数据库表名称。 For example, User entity could be stored in uzer table.
例如, 用户实体可以存储在uzer表中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.