Pessoal, seguinte: Sou novato com Persistência, Hibernate, etc, etc. Estou fazendo uns testes com o Netbeans e me deparei com o seguinte problema:
Usando o Netbeans 6.9, criei uma nova aplicação de exemplo:
“Aplicativo da área de trabalho Java”, e escolhi como sendo o shell do aplicativo, “Aplicativo do banco de dados”.
Criei um novo banco de dados de teste no PostgreSQL, que é o banco de dados que estou usando. (A imagem do MER e o Script que gera as tabelas estão anexos)
Quando tento rodar a aplicação de teste gerada automaticamente pelo Netbeans (sem mexer), ele dá um erro. Já tentei apagar e criar a aplicação novamente e o erro continua a aparecer no momento de executar a aplicação.
Uma coisa que notei é que a chamada que ele faz ao banco de dados, tras o seguinte codigo SQL:
Call: SELECT pessoa_id, cliente_data FROM Pessoa.public.cliente
Se eu executar esse comando diretamente no Postgre, ele dá erro também…
Porém se eu mudar para SELECT pessoa_id, cliente_data FROM public.cliente
eliminando o nome do banco de dados “Pessoa” da cláusula FROM, ele executa sem erro.
Acontece que esse código é gerado automaticamente pelo Hibernate ou TopLink, sei lá, e dentro do codigo escrito pelo Netbeans consigo apenas encontrar a parte que ele se referencia ao banco de dados “Pessoa” na seguinte parte:
@Entity
@Table(name = "cliente", catalog = "Pessoa", schema = "public")
@NamedQueries({
@NamedQuery(name = "Cliente.findAll", query = "SELECT c FROM Cliente c"),
@NamedQuery(name = "Cliente.findByPessoaId", query = "SELECT c FROM Cliente c WHERE c.pessoaId = :pessoaId"),
@NamedQuery(name = "Cliente.findByClienteData", query = "SELECT c FROM Cliente c WHERE c.clienteData = :clienteData")})
public class Cliente implements Serializable {
Bom, nem tenho ideia de como resolver… queria rodar o exemplo pra começar a fazer uns testes. Se alguém puder me ajudar…
Segue o erro ao rodar a aplicação:
[TopLink Info]: 2010.12.02 11:08:41.169--ServerSession(1864311781)--TopLink, version: Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))
[TopLink Info]: 2010.12.02 11:08:41.678--ServerSession(1864311781)--file:/C:/Users/Adriano/Documents/NetBeansProjects/DesktopApplication1/build/classes/-PessoaPU login successful
[TopLink Warning]: 2010.12.02 11:08:41.731--UnitOfWork(947883563)--Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERRO: referências cruzadas entre bancos de dados não estão implementadas: "pessoa.public.cliente"
Error Code: 0
Call: SELECT pessoa_id, cliente_data FROM Pessoa.public.cliente
Query: ReportQuery(desktopapplication1.Cliente)
02/12/2010 11:08:41 org.jdesktop.application.Application$1 run
GRAVE: Application class desktopapplication1.DesktopApplication1 failed to launch
Local Exception Stack:
Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERRO: referências cruzadas entre bancos de dados não estão implementadas: "pessoa.public.cliente"
Error Code: 0
Call: SELECT pessoa_id, cliente_data FROM Pessoa.public.cliente
Query: ReportQuery(desktopapplication1.Cliente)
at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:319)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:566)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:452)
at oracle.toplink.essentials.threetier.ServerSession.executeCall(ServerSession.java:473)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:214)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:285)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:615)
at oracle.toplink.essentials.internal.queryframework.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2416)
at oracle.toplink.essentials.internal.queryframework.ExpressionQueryMechanism.selectAllReportQueryRows(ExpressionQueryMechanism.java:2382)
at oracle.toplink.essentials.queryframework.ReportQuery.executeDatabaseQuery(ReportQuery.java:802)
at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:628)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:692)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:746)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2233)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:952)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:924)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:367)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getResultList(EJBQueryImpl.java:478)
at desktopapplication1.DesktopApplication1View.initComponents(DesktopApplication1View.java:285)
at desktopapplication1.DesktopApplication1View.<init>(DesktopApplication1View.java:36)
at desktopapplication1.DesktopApplication1.startup(DesktopApplication1.java:19)
at org.jdesktop.application.Application$1.run(Application.java:171)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: org.postgresql.util.PSQLException: ERRO: referências cruzadas entre bancos de dados não estão implementadas: "pessoa.public.cliente"
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1592)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1327)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:192)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:350)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:726)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:501)
... 29 more
Exception in thread "AWT-EventQueue-0" java.lang.Error: Application class desktopapplication1.DesktopApplication1 failed to launch
at org.jdesktop.application.Application$1.run(Application.java:177)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERRO: referências cruzadas entre bancos de dados não estão implementadas: "pessoa.public.cliente"
Error Code: 0
Call: SELECT pessoa_id, cliente_data FROM Pessoa.public.cliente
Query: ReportQuery(desktopapplication1.Cliente)
at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:319)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:566)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:452)
at oracle.toplink.essentials.threetier.ServerSession.executeCall(ServerSession.java:473)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:214)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:285)
at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:615)
at oracle.toplink.essentials.internal.queryframework.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2416)
at oracle.toplink.essentials.internal.queryframework.ExpressionQueryMechanism.selectAllReportQueryRows(ExpressionQueryMechanism.java:2382)
at oracle.toplink.essentials.queryframework.ReportQuery.executeDatabaseQuery(ReportQuery.java:802)
at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:628)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:692)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:746)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2233)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:952)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:924)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:367)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getResultList(EJBQueryImpl.java:478)
at desktopapplication1.DesktopApplication1View.initComponents(DesktopApplication1View.java:285)
at desktopapplication1.DesktopApplication1View.<init>(DesktopApplication1View.java:36)
at desktopapplication1.DesktopApplication1.startup(DesktopApplication1.java:19)
at org.jdesktop.application.Application$1.run(Application.java:171)
... 8 more
Caused by: org.postgresql.util.PSQLException: ERRO: referências cruzadas entre bancos de dados não estão implementadas: "pessoa.public.cliente"
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1592)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1327)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:192)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:350)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:726)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:501)
... 29 more