NetBeans + Hibernate + PostGres

时间:2016-05-20 19:16:32

标签: hibernate netbeans

的Env。描述: - Netbeans 8.1 - MacOS El Capitan - PostGres 9.2

遵循本手册: https://netbeans.org/kb/docs/web/hibernate-webapp.html

我正面临以下问题: 如果我在NetBeans IDE中打开HQL查询窗口, 并发出以下命令:

from company

请注意,公司表中确实存在公司表,并且已配置hibernate.xml以反映该事实。

,我收到此错误:

    org.hibernate.exception.SQLGrammarException: could not extract ResultSet
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:123)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:89)
at org.hibernate.loader.Loader.getResultSet(Loader.java:2065)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1862)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1838)
at org.hibernate.loader.Loader.doQuery(Loader.java:909)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
at org.hibernate.loader.Loader.doList(Loader.java:2551)
at org.hibernate.loader.Loader.doList(Loader.java:2537)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2367)
at org.hibernate.loader.Loader.list(Loader.java:2362)
at org.hibernate.hql.internal.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:939)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:229)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1260)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)

引起:org.postgresql.util.PSQLException:错误:语法错误在“from”或附近   职位:9     at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2157)     at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1886)     at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)     at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:555)     at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)     at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:302)     at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:80)     ......还有15个

如果我只是打开NetBeans IDE并连接到数据库,请转到“服务”选项卡,我可以连接到数据库并发出任何命令。

您能帮忙或指导我找到解决方案吗?

谢谢。

1 个答案:

答案 0 :(得分:0)

也许我错误地描述了这个问题。 但是,我在这里找到了答案:Hibernate error when using HQL Editor to query