2013-10-04 26 views
1

和PostgreSQL綁定表,在NetBeans中設計形式的表格後,我得到了以下錯誤:錯誤而來自PostgreSQL數據庫的表結合的Netbeans GUI表

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) 

我應該怎麼做來解決錯誤?

回答

1

我有IntelliJ IDEA的和Hybernate同樣的錯誤,

造成的:org.postgresql.util.PSQLException:ERROR:跨數據庫引用沒有實現: 「mydb.public.media_types」

和你一樣,

造成的:org.postgresql.util.PSQLException:ERROR:跨數據庫引用不落實:

我已經找到了解決方案,我的麻煩「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。 看到,這些鏈接,瞭解詳細信息:

hibernate-using-two-different-database-schemas-in-the-same-application

how-to-connect-to-multiple-databases-in-hibernate