当我尝试使用JPA/hibernate持久化一个名为"user"的实体时,它不起作用.该表未创建,因为user是postgresql中的保留字.除了命名表之外还有什么方法可以使其工作吗?
我正在通过Hibernate(注释)使用Postgres,但它似乎在处理User对象时失败了:
12:09:16,442 ERROR [SchemaExport] Unsuccessful: create table User (id bigserial not null, password varchar(255), username varchar(255), primary key (id))
12:09:16,442 ERROR [SchemaExport] ERROR: syntax error at or near "User"
Run Code Online (Sandbox Code Playgroud)
如果我手动运行SQL,我必须在表名周围加上引号,因为用户似乎是一个postgres关键字,但我怎么能说服hibernate自己做呢?
提前致谢.
我正在开发一个应用程序,其中使用 hibernate 和 postgresql 并给出以下错误
org.postgresql.util.PSQLException:错误:“调用”处或附近存在语法错误
有人可以告诉我哪里出了问题吗?我正在使用 Postgres 9.4。
HTTP Status 500 - Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not get next sequence value
type Exception report
message Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not get next sequence value
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not get next sequence value
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:659)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563)
javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
org.hibernate.exception.SQLGrammarException: …Run Code Online (Sandbox Code Playgroud)