相关疑难解决方法(0)

无法在postgresql hibernate中使用名为"user"的表

当我尝试使用JPA/hibernate持久化一个名为"user"的实体时,它不起作用.该表未创建,因为user是postgresql中的保留字.除了命名表之外还有什么方法可以使其工作吗?

postgresql hibernate jpa

19
推荐指数
5
解决办法
1万
查看次数

Hibernate将用户模型保存到Postgres

我正在通过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自己做呢?

提前致谢.

java postgresql orm hibernate

18
推荐指数
1
解决办法
7525
查看次数

异常:org.postgresql.util.PSQLException:错误:“调用”处或附近的语法错误

我正在开发一个应用程序,其中使用 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)

java postgresql hibernate postgresql-9.4

3
推荐指数
1
解决办法
6956
查看次数

标签 统计

hibernate ×3

postgresql ×3

java ×2

jpa ×1

orm ×1

postgresql-9.4 ×1