1

将 postgresql 中的表绑定到 Netbeans 中设计表单中的表后,出现以下错误:

run:
[EL Info]: 2013-10-04 10:51:36.097--ServerSession(865393238)--EclipseLink, version: Eclipse Persistence Services - 2.5.0.v20130507-3faac2b
[EL Info]: connection: 2013-10-04 10:51:36.701--ServerSession(865393238)--file:/D:/Doodle Notes Database/Doodle Notes Projects/build/classes/_DoodleNotesPU login successful
[EL Warning]: 2013-10-04 10:51:37.119--UnitOfWork(1785038318)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: cross-database references are not implemented: "doodlenotes.public.projects"
  Position: 139
Error Code: 0
Exception in thread "main" javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: cross-database references are not implemented: "doodlenotes.public.projects"
Call: SELECT project_code, member_incharge, project_category, project_client, project_genre, project_name, project_package, project_status FROM DoodleNotes.public.projects
  Position: 139
Error Code: 0
Query: ReadAllQuery(referenceClass=Projects sql="SELECT project_code, member_incharge, project_category, project_client, project_genre, project_name, project_package, project_status FROM DoodleNotes.public.projects")
Call: SELECT project_code, member_incharge, project_category, project_client, project_genre, project_name, project_package, project_status FROM DoodleNotes.public.projects
Query: ReadAllQuery(referenceClass=Projects sql="SELECT project_code, member_incharge, project_category, project_client, project_genre, project_name, project_package, project_status FROM DoodleNotes.public.projects")
    at org.eclipse.persistence.internal.jpa.QueryImpl.getDetailedException(QueryImpl.java:377)
    at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:260)
    at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:468)
    at Doodle.doodleNotes_Business.initComponents(doodleNotes_Business.java:26)
    at Doodle.doodleNotes_Business.<init>(doodleNotes_Business.java:11)
    at Doodle.doodleNotes_Business.main(doodleNotes_Business.java:311)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: cross-database references are not implemented: "doodlenotes.public.projects"
  Position: 139
Error Code: 0
Call: SELECT project_code, member_incharge, project_category, project_client, project_genre, project_name, project_package, project_status FROM DoodleNotes.public.projects
Query: ReadAllQuery(referenceClass=Projects sql="SELECT project_code, member_incharge, project_category, project_client, project_genre, project_name, project_package, project_status FROM DoodleNotes.public.projects")
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:679)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:558)
    at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1995)
    at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:570)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:242)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:299)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:694)
    at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2714)
    at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2667)
    at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:477)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1155)
    at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1114)
    at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:402)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1202)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2894)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1744)
    at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
    ... 4 more
Caused by: org.postgresql.util.PSQLException: ERROR: cross-database references are not implemented: "doodlenotes.public.projects"
  Position: 139
    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.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:1002)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:641)
    ... 24 more
Java Result: 1
BUILD SUCCESSFUL (total time: 5 seconds)

我应该怎么做才能修复错误?

4

1 回答 1

1

我对 IntelliJ IDEA 和 Hybernate 有同样的错误,

引起:org.postgresql.util.PSQLException:错误:未实现跨数据库引用:“mydb.public.media_types”

和你的一样,

引起:org.postgresql.util.PSQLException:错误:未实现跨数据库引用:“doodlenotes.public.projects”

对于我的麻烦,我已经找到了解决方案,我想对于您的问题,我的解决方案只是从我的 hbm.xml 文件中删除名为 catalog 的属性。

前:

`<class name="pkg.MediaTypesEntity" table="media_types" schema="public"` catalog="MyDB">

后:

<!-- catalog="MyDB" --removed -->
<class name="pkg.MediaTypesEntity" table="media_types" schema="public">
<!-- catalog="MyDB" --removed -->
    <id name="id">
        <column name="id" sql-type="serial" not-null="true"/>
    </id>
    <property name="txt">
        <column name="txt" sql-type="text" length="2147483647"/>
    </property>
</class>

我想原因是数据库名称是在 hibernate.cfg.xml 全局配置的。

<hibernate-configuration>
    <session-factory>

        <property name="connection.url">jdbc:postgresql://localhost:5432/MyDB</property>

        <property name="connection.driver_class">org.postgresql.Driver</property>
        <mapping resource="pkg/MediaTypesEntity.hbm.xml"/>
        <mapping class="pkg.MediaTypesEntity"/>
    </session-factory>
</hibernate-configuration>

而且,真正的原因是,MyDB 名称不能轻易地从 JDBC 连接字符串中删除。只允许使用几种不同的 hibernate-DBName.cfg.xml。有关详细信息,请参阅这些链接:

休眠使用两个不同的数据库模式在同一个应用程序中

如何连接到休眠中的多个数据库

于 2014-09-14T07:04:12.590 回答